Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Nov 2, 2023
1 parent 3ae4272 commit ffe8f45
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/backend/app/projects/project_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,9 @@ async def read_project_summaries(
total_pages = (total_projects + results_per_page - 1) // results_per_page

projects = project_crud.get_project_summaries(db, user_id, skip, limit, hashtags)
project_summaries = [project_schemas.ProjectSummary.from_db_project(project) for project in projects]
project_summaries = [
project_schemas.ProjectSummary.from_db_project(project) for project in projects
]

response = project_schemas.PaginatedProjectSummaries(
results=project_summaries,
Expand Down
12 changes: 9 additions & 3 deletions src/backend/app/projects/project_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
from geojson_pydantic import Feature as GeojsonFeature
from pydantic import BaseModel

from ..db import db_models
from ..models.enums import ProjectPriority, ProjectStatus
from ..tasks import tasks_schemas
from ..users.user_schemas import User
from ..db import db_models


class ODKCentral(BaseModel):
Expand Down Expand Up @@ -78,11 +78,14 @@ class ProjectSummary(BaseModel):
organisation_logo: Optional[str] = None

@classmethod
def from_db_project(cls, project: db_models.DbProject,) -> "ProjectSummary":
def from_db_project(
cls,
project: db_models.DbProject,
) -> "ProjectSummary":
priority = project.priority
return cls(
id=project.id,
priority= priority,
priority=priority,
priority_str=priority.name,
title=project.title,
location_str=project.location_str,
Expand All @@ -97,6 +100,7 @@ def from_db_project(cls, project: db_models.DbProject,) -> "ProjectSummary":
organisation_logo=project.organisation_logo,
)


class PaginationInfo(BaseModel):
hasNext: bool
hasPrev: bool
Expand All @@ -107,10 +111,12 @@ class PaginationInfo(BaseModel):
perPage: int
total: int


class PaginatedProjectSummaries(BaseModel):
results: List[ProjectSummary]
pagination: PaginationInfo


class ProjectBase(BaseModel):
id: int
odkid: int
Expand Down

0 comments on commit ffe8f45

Please sign in to comment.