Skip to content

Commit 7099541

Browse files
authored
Merge pull request #476 from mapswipe/fix-tasks-in-firebase-for-change-detection
upload tasks in firebase for change detection project type
2 parents d385eb8 + 7914fb2 commit 7099541

File tree

1 file changed

+16
-7
lines changed
  • mapswipe_workers/mapswipe_workers/project_types/base

1 file changed

+16
-7
lines changed

mapswipe_workers/mapswipe_workers/project_types/base/project.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -215,20 +215,29 @@ def save_to_firebase(self, project, groups, groupsOfTasks):
215215
logger.info(f"there are {len(groupsOfTasks)} groups for this project")
216216
group_counter = 0
217217

218-
if self.projectType in [ProjectType.FOOTPRINT.value]:
219-
# The building footprint project type is the only one
220-
# that uses tasks in Firebase.
218+
if self.projectType in [
219+
ProjectType.FOOTPRINT.value,
220+
ProjectType.CHANGE_DETECTION.value,
221+
]:
222+
# The change detection and building footprint project types
223+
# use tasks in Firebase.
224+
# These tasks are compressed for building footprint type.
221225
for group_id in groupsOfTasks.keys():
222226
tasks_list = groupsOfTasks[group_id]
223227
group_counter += 1
224228
# for tasks of a building footprint project
225229
# we use compression to reduce storage size in firebase
226230
# since the tasks hold geometries their storage size
227231
# can get quite big otherwise
228-
compressed_tasks = gzip_str.compress_tasks(tasks_list)
229-
task_upload_dict[
230-
f"v2/tasks/{self.projectId}/{group_id}"
231-
] = compressed_tasks
232+
if self.projectType in [ProjectType.FOOTPRINT.value]:
233+
compressed_tasks = gzip_str.compress_tasks(tasks_list)
234+
task_upload_dict[
235+
f"v2/tasks/{self.projectId}/{group_id}"
236+
] = compressed_tasks
237+
else:
238+
task_upload_dict[
239+
f"v2/tasks/{self.projectId}/{group_id}"
240+
] = tasks_list
232241

233242
# we upload tasks in batches of maximum 150 groups
234243
# this is to avoid the maximum write size limit in firebase

0 commit comments

Comments
 (0)