Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: database calls for homepage #351

Merged
merged 3 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions backend/zeno_backend/classes/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,18 @@ class ProjectStats(CamelModel):
user_liked: bool


class ProjectDetails(CamelModel):
"""Project and details for homepage rendering.
class ProjectsDetails(CamelModel):
"""Projects and details for homepage rendering.

Attributes:
project (Project): project object with project metadata.
statistics (ProjectStats): project statistics.
projects (list[Project]): project object with project metadata.
statistics (list[ProjectStats]): project statistics.
num_projects (int): number of projects.
"""

project: Project
statistics: ProjectStats
projects: list[Project]
statistics: list[ProjectStats]
num_projects: int


class ProjectState(CamelModel):
Expand Down Expand Up @@ -103,3 +105,17 @@ class ProjectCopy(CamelModel):
copy_systems: bool
copy_slices: bool
copy_charts: bool


class ProjectsRequest(CamelModel):
"""Request for a list of projects.

Attributes:
offset (int): offset to query projects table.
limit (int): limit to query projects table.
order (str): order to sort query with.
"""

offset: int = 0
limit: int | None = None
order: str | None = None
27 changes: 21 additions & 6 deletions backend/zeno_backend/classes/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,17 @@ class ReportStats(CamelModel):
user_liked: bool = False


class ReportDetails(CamelModel):
"""Report and details for homepage rendering.
class ReportsDetails(CamelModel):
"""Reports and details for homepage rendering.

Attributes:
report (Report): report object with report metadata.
statistics (ReportStats): report statistics.
reports (list[Report]): report object with report metadata.
statistics (list[ReportStats]): report statistics.
cabreraalex marked this conversation as resolved.
Show resolved Hide resolved
"""

report: Report
statistics: ReportStats
reports: list[Report]
statistics: list[ReportStats]
num_reports: int


class SliceElementSpec(CamelModel):
Expand Down Expand Up @@ -122,3 +123,17 @@ class SliceElementOptions(CamelModel):
data_column: str | None = None
label_column: str | None = None
model_column: str | None = None


class ReportsRequest(CamelModel):
"""Request for reports in Zeno.

Attributes:
offset (int): offset of the first report to get.
limit (int): number of reports to get.
order (str): order of the reports.
"""

offset: int = 0
limit: int | None = None
order: str | None = None
Loading
Loading