From eb0865662ceede0ad560f6c0a640496577c45347 Mon Sep 17 00:00:00 2001 From: allegroai <> Date: Tue, 4 Feb 2020 18:21:04 +0200 Subject: [PATCH] Fix projects aggregation on tasks with invalid status --- server/services/projects.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/server/services/projects.py b/server/services/projects.py index 78829ce..c7dc548 100644 --- a/server/services/projects.py +++ b/server/services/projects.py @@ -61,7 +61,7 @@ def get_by_id(call): def make_projects_get_all_pipelines(project_ids, specific_state=None): archived = EntityVisibility.archived.value - def ensure_system_tags(): + def ensure_valid_fields(): """ Make sure system tags is always an array (required by subsequent $in in archived_tasks_cond """ @@ -73,6 +73,9 @@ def make_projects_get_all_pipelines(project_ids, specific_state=None): "then": [], "else": "$system_tags", } + }, + "status": { + "$ifNull": ["$status", "unknown"] } } } @@ -80,7 +83,7 @@ def make_projects_get_all_pipelines(project_ids, specific_state=None): status_count_pipeline = [ # count tasks per project per status {"$match": {"project": {"$in": project_ids}}}, - ensure_system_tags(), + ensure_valid_fields(), { "$group": { "_id": { @@ -153,7 +156,7 @@ def make_projects_get_all_pipelines(project_ids, specific_state=None): "project": {"$in": project_ids}, } }, - ensure_system_tags(), + ensure_valid_fields(), { # for each project "$group": group_step