Skip to content

Commit 68cd66f

Browse files
committed
fix: fix creation of footprint tutorial
1 parent e4ab896 commit 68cd66f

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

mapswipe_workers/mapswipe_workers/firebase/firebase.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,13 @@ def delete_project_draft_from_firebase(self, projectId):
6666
)
6767

6868
def save_tutorial_to_firebase(
69-
self, tutorial, groups, groupsOfTasks, useCompression: bool
69+
self, tutorial, groups: dict, groupsOfTasks: dict, useCompression: bool
7070
):
71-
tasks = {k: [asdict(i) for i in v] for k, v in groupsOfTasks.items()}
71+
if useCompression:
72+
tasks = {101: gzip_str.compress_tasks(groupsOfTasks[101])}
73+
else:
74+
tasks = {k: [asdict(i) for i in v] for k, v in groupsOfTasks.items()}
75+
7276
groups = {k: asdict(v) for k, v in groups.items()}
7377

7478
tutorialDict = vars(tutorial)
@@ -86,11 +90,6 @@ def save_tutorial_to_firebase(
8690
f"Project Id is invalid: {tutorial.projectId}"
8791
)
8892

89-
if useCompression:
90-
# we compress tasks for footprint project type using gzip
91-
compressed_tasks = gzip_str.compress_tasks(groupsOfTasks)
92-
tasks = {"101": compressed_tasks}
93-
9493
self.ref.update(
9594
{
9695
f"v2/projects/{tutorial.projectId}": tutorialDict,

mapswipe_workers/mapswipe_workers/project_types/arbitrary_geometry/tutorial.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def __init__(self, tutorial_draft):
3434
self.tileServer = vars(BaseTileServer(tutorial_draft["tileServer"]))
3535
self.tutorial_tasks = tutorial_draft["tutorialTasks"]
3636
self.groups = dict()
37-
self.tasks = []
37+
self.tasks = dict()
3838

3939
# save tasks as geojson
4040
self.inputGeometries = (
@@ -54,16 +54,15 @@ def create_tutorial_groups(self):
5454
group = ArbitraryGeometryGroup(
5555
groupId=101,
5656
projectId=self.projectId,
57-
numberOfTasks=0,
57+
numberOfTasks=len(self.tutorial_tasks["features"]),
5858
progress=0,
5959
finishedCount=0,
6060
requiredCount=0,
6161
)
62-
self.groups[101] = asdict(group)
62+
self.groups[101] = group
6363

6464
# Add number of tasks for the group here. This needs to be set according to
6565
# the number of features/examples in the geojson file
66-
self.groups[101]["numberOfTasks"] = len(self.tutorial_tasks["features"])
6766

6867
logger.info(
6968
f"{self.projectId}"
@@ -102,7 +101,7 @@ def create_tutorial_tasks(self):
102101
)
103102
task_list.append(asdict(task))
104103
if task_list:
105-
self.tasks = task_list
104+
self.tasks[101] = task_list
106105
else:
107106
# remove group if it would contain no tasks
108107
self.groups.pop(group_id)

0 commit comments

Comments
 (0)