Skip to content

Commit

Permalink
Add to_external() method for projects summary
Browse files Browse the repository at this point in the history
  • Loading branch information
EddieLF committed Sep 14, 2023
1 parent 0a352b4 commit d59acb7
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 5 deletions.
4 changes: 3 additions & 1 deletion api/routes/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ async def get_projects_summary(
"""
Get the project summaries
"""
return [
summaries = [
ProjectsSummaryInternal(
project=1,
dataset='test-dataset-1',
Expand Down Expand Up @@ -176,6 +176,8 @@ async def get_projects_summary(
total_sgs_in_latest_annotate_dataset=4,
),
]

return [s.to_external() for s in summaries]
return await WebLayer(get_projectless_db_connection).get_projects_summary(
sequencing_types=sequencing_types
)
46 changes: 42 additions & 4 deletions models/models/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,52 @@ class ProjectsSummaryInternal:
total_sequencing_groups: int
total_crams: int
latest_es_index_id: int
# latest_es_index_output: str
# latest_es_index_timestamp: str
total_sgs_in_latest_es_index: int
latest_annotate_dataset_id: int
# latest_annotate_dataset_output: str
# latest_annotate_dataset_timestamp: str
total_sgs_in_latest_annotate_dataset: int

def to_external(self, links):
"""Convert to transport model"""
return ProjectsSummary(
project=self.project,
dataset=self.dataset,
sequencing_type=self.sequencing_type,
total_families=self.total_families,
total_participants=self.total_participants,
total_samples=self.total_samples,
total_sequencing_groups=self.total_sequencing_groups,
total_crams=self.total_crams,
latest_es_index_id=self.latest_es_index_id,
total_sgs_in_latest_es_index=self.total_sgs_in_latest_es_index,
latest_annotate_dataset_id=self.latest_annotate_dataset_id,
total_sgs_in_latest_annotate_dataset=self.total_sgs_in_latest_annotate_dataset,
links=links,
)


class ProjectsSummary:
"""Return class for the projects summary endpoint"""

project: int
dataset: str
sequencing_type: str
total_families: int
total_participants: int
total_samples: int
total_sequencing_groups: int
total_crams: int
latest_es_index_id: int
total_sgs_in_latest_es_index: int
latest_annotate_dataset_id: int
total_sgs_in_latest_annotate_dataset: int

links: PagingLinks | None

class Config:
"""Config for ProjectsSummaryResponse"""

fields = {'links': '_links'}


@dataclasses.dataclass
class ProjectSummaryInternal:
Expand Down

0 comments on commit d59acb7

Please sign in to comment.