diff --git a/api/routes/web.py b/api/routes/web.py index 57156d294..ece970bc0 100644 --- a/api/routes/web.py +++ b/api/routes/web.py @@ -132,7 +132,7 @@ async def get_projects_summary( """ Get the project summaries """ - return [ + summaries = [ ProjectsSummaryInternal( project=1, dataset='test-dataset-1', @@ -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 ) diff --git a/models/models/web.py b/models/models/web.py index 25382a7ec..30746b8ca 100644 --- a/models/models/web.py +++ b/models/models/web.py @@ -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: