mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-12-24 11:15:15 -05:00
* Remove some implicit lazy-loads from user serialization * implement full backup restore across different database versions * rework all custom getter dicts to not leak lazy loads * remove some occurances of lazy-loading * remove a lot of lazy loading from recipes * add more eager loading remove loading options from repository remove raiseload for checking * fix failing test * do not apply loader options for paging counts * try using selectinload a bit more instead of joinedload * linter fixes
63 lines
1.4 KiB
Python
63 lines
1.4 KiB
Python
import datetime
|
|
import enum
|
|
|
|
from pydantic import Field
|
|
from pydantic.types import UUID4
|
|
from sqlalchemy.orm import joinedload
|
|
from sqlalchemy.orm.interfaces import LoaderOption
|
|
|
|
from mealie.db.models.group import ReportModel
|
|
from mealie.schema._mealie import MealieModel
|
|
|
|
|
|
class ReportCategory(str, enum.Enum):
|
|
backup = "backup"
|
|
restore = "restore"
|
|
migration = "migration"
|
|
bulk_import = "bulk_import"
|
|
|
|
|
|
class ReportSummaryStatus(str, enum.Enum):
|
|
in_progress = "in-progress"
|
|
success = "success"
|
|
failure = "failure"
|
|
partial = "partial"
|
|
|
|
|
|
class ReportEntryCreate(MealieModel):
|
|
report_id: UUID4
|
|
timestamp: datetime.datetime = Field(default_factory=datetime.datetime.utcnow)
|
|
success: bool = True
|
|
message: str
|
|
exception: str = ""
|
|
|
|
|
|
class ReportEntryOut(ReportEntryCreate):
|
|
id: UUID4
|
|
|
|
class Config:
|
|
orm_mode = True
|
|
|
|
|
|
class ReportCreate(MealieModel):
|
|
timestamp: datetime.datetime = Field(default_factory=datetime.datetime.utcnow)
|
|
category: ReportCategory
|
|
group_id: UUID4
|
|
name: str
|
|
status: ReportSummaryStatus = ReportSummaryStatus.in_progress
|
|
|
|
|
|
class ReportSummary(ReportCreate):
|
|
id: UUID4
|
|
|
|
|
|
class ReportOut(ReportSummary):
|
|
entries: list[ReportEntryOut] = []
|
|
|
|
class Config:
|
|
orm_mode = True
|
|
|
|
@classmethod
|
|
def loader_options(cls) -> list[LoaderOption]:
|
|
return [joinedload(ReportModel.entries)]
|