diff --git a/apiserver/apimodels/projects.py b/apiserver/apimodels/projects.py index a9c9e56..3f2e8eb 100644 --- a/apiserver/apimodels/projects.py +++ b/apiserver/apimodels/projects.py @@ -53,6 +53,7 @@ class ProjectHyperparamValuesRequest(MultiProjectRequest): class ProjectsGetRequest(models.Base): include_stats = fields.BoolField(default=False) + stats_with_children = fields.BoolField(default=True) stats_for_state = ActualEnumField(EntityVisibility, default=EntityVisibility.active) non_public = fields.BoolField(default=False) active_users = fields.ListField(str) diff --git a/apiserver/bll/project/project_bll.py b/apiserver/bll/project/project_bll.py index 4afb55d..fc6d634 100644 --- a/apiserver/bll/project/project_bll.py +++ b/apiserver/bll/project/project_bll.py @@ -456,11 +456,16 @@ class ProjectBLL: company: str, project_ids: Sequence[str], specific_state: Optional[EntityVisibility] = None, + include_children: bool = True, ) -> Tuple[Dict[str, dict], Dict[str, dict]]: if not project_ids: return {}, {} - child_projects = _get_sub_projects(project_ids, _only=("id", "name")) + child_projects = ( + _get_sub_projects(project_ids, _only=("id", "name")) + if include_children + else {} + ) project_ids_with_children = set(project_ids) | { c.id for c in itertools.chain.from_iterable(child_projects.values()) } diff --git a/apiserver/schema/services/projects.conf b/apiserver/schema/services/projects.conf index b8f4806..4552b6d 100644 --- a/apiserver/schema/services/projects.conf +++ b/apiserver/schema/services/projects.conf @@ -539,6 +539,13 @@ get_all_ex { description: "Scroll ID that can be used with the next calls to get_all to retrieve more data" } } + "999.0": ${get_all_ex."2.15"} { + response.properties.stats_with_children { + description: "If include_stats flag is set then this flag contols whether the child projects tasks are taken into statistics or not" + type: boolean + default: true + } + } } update { "2.1" { diff --git a/apiserver/services/projects.py b/apiserver/services/projects.py index 62bb5ee..105bc2e 100644 --- a/apiserver/services/projects.py +++ b/apiserver/services/projects.py @@ -140,6 +140,7 @@ def get_all_ex(call: APICall, company_id: str, request: ProjectsGetRequest): company=company_id, project_ids=list(project_ids), specific_state=request.stats_for_state, + include_children=request.stats_with_children, ) for project in projects: