Skip to content

Commit a7f6b80

Browse files
committed
Fix footprint time threshold calculation logic
1 parent ec64f11 commit a7f6b80

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

django/apps/aggregated/management/commands/update_aggregated_data.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,15 @@
7373
G.group_id = GD.group_id;
7474
"""
7575

76-
TASK_GROUP_METADATA_QUERY = """
76+
TASK_GROUP_METADATA_QUERY = f"""
7777
SELECT
78-
G.project_id,
78+
P.project_id,
7979
G.group_id,
80-
G.total_area as total_task_group_area,
80+
CASE
81+
-- Hide area for Footprint
82+
WHEN P.project_type = {Project.Type.FOOTPRINT.value} THEN 0
83+
ELSE G.total_area
84+
) as total_task_group_area,
8185
G.time_spent_max_allowed
8286
FROM groups G
8387
INNER JOIN used_task_groups UG USING (project_id, group_id)
@@ -106,9 +110,7 @@
106110
FROM mapping_sessions MS
107111
INNER JOIN projects P USING (project_id)
108112
WHERE
109-
-- Skip for footprint type missions
110-
P.project_type != {Project.Type.FOOTPRINT.value}
111-
AND MS.start_time >= %(from_date)s
113+
MS.start_time >= %(from_date)s
112114
AND MS.start_time < %(until_date)s
113115
GROUP BY project_id, project_type, group_id -- To get unique
114116
),
@@ -185,9 +187,7 @@
185187
INNER JOIN mapping_sessions MS USING (mapping_session_id)
186188
INNER JOIN projects P USING (project_id)
187189
WHERE
188-
-- Skip for footprint type missions
189-
P.project_type != {Project.Type.FOOTPRINT.value}
190-
AND MS.start_time >= %(from_date)s
190+
MS.start_time >= %(from_date)s
191191
AND MS.start_time < %(until_date)s
192192
GROUP BY project_id, project_type, group_id -- To get unique
193193
),

0 commit comments

Comments
 (0)