Skip to content

Commit 2616fed

Browse files
authored
Merge pull request #610 from mapswipe/feature/skip-footprint-area
Skip footprint mission area swiped.
2 parents 03527eb + ee3ce33 commit 2616fed

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

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

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,17 @@
2525
-- Retrieve used task groups
2626
WITH used_task_groups as (
2727
SELECT
28-
MS.project_id, MS.group_id
28+
MS.project_id,
29+
MS.group_id
2930
FROM mapping_sessions MS
31+
INNER JOIN projects P USING (project_id)
3032
WHERE
3133
MS.start_time >= %(from_date)s and MS.start_time < %(until_date)s
34+
AND P.project_type != 2 -- Skip for footprint type missions
3235
GROUP BY project_id, group_id -- To get unique
3336
),
3437
-- Calculated area by task_groups
35-
task_group_data as (
38+
task_group_area_data as (
3639
SELECT
3740
project_id,
3841
group_id,
@@ -53,9 +56,9 @@
5356
MS.start_time,
5457
MS.end_time,
5558
MS.items_count as task_count,
56-
TG.total_task_group_area as area_swiped
59+
Coalesce(TG.total_task_group_area, 0) as area_swiped
5760
FROM mapping_sessions MS
58-
INNER JOIN task_group_data TG USING (project_id, group_id)
61+
LEFT JOIN task_group_area_data TG USING (project_id, group_id)
5962
WHERE
6063
MS.start_time >= %(from_date)s and MS.start_time < %(until_date)s
6164
),
@@ -105,15 +108,18 @@
105108
-- Retrieve used task groups
106109
WITH used_task_groups as (
107110
SELECT
108-
MS.project_id, MS.group_id
111+
MS.project_id,
112+
MS.group_id
109113
From mapping_sessions_user_groups MSUR
110114
INNER JOIN mapping_sessions MS USING (mapping_session_id)
115+
INNER JOIN projects P USING (project_id)
111116
WHERE
112117
MS.start_time >= %(from_date)s and MS.start_time < %(until_date)s
118+
AND P.project_type != 2 -- Skip for footprint type missions
113119
GROUP BY project_id, group_id -- To get unique
114120
),
115121
-- Calculated area by task_groups
116-
task_group_data as (
122+
task_group_area_data as (
117123
SELECT
118124
project_id,
119125
group_id,
@@ -135,10 +141,10 @@
135141
MS.start_time as start_time,
136142
MS.end_time as end_time,
137143
MS.items_count as task_count,
138-
TG.total_task_group_area as area_swiped
144+
Coalesce(TG.total_task_group_area, 0) as area_swiped
139145
From mapping_sessions_user_groups MSUR
140146
INNER JOIN mapping_sessions MS USING (mapping_session_id)
141-
INNER JOIN task_group_data TG USING (project_id, group_id)
147+
LEFT JOIN task_group_area_data TG USING (project_id, group_id)
142148
WHERE
143149
MS.start_time >= %(from_date)s and MS.start_time < %(until_date)s
144150
),

mapswipe_workers/mapswipe_workers/firebase_to_postgres/transfer_results.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ def transfer_results_for_project(project_id, results, filter_mode: bool = False)
8888
[
8989
user_group_id
9090
for _, users in results.items()
91-
for _, results in users.items()
92-
for user_group_id, is_selected in results.get(
91+
for _, _results in users.items()
92+
for user_group_id, is_selected in _results.get(
9393
"userGroups", {}
9494
).items()
9595
if is_selected

nginx/nginx.conf.template

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ server {
5151

5252
location / {
5353
proxy_pass http://django:80/;
54+
proxy_cache_valid 502 503 0; # Don't cache this error code.
5455
proxy_set_header Connection "upgrade";
5556
proxy_set_header Upgrade $http_upgrade;
5657
proxy_set_header Host $host;

0 commit comments

Comments
 (0)