Skip to content

Commit c10693e

Browse files
author
Herfort
committed
fix NoneType in delete results
1 parent dc4f29f commit c10693e

File tree

2 files changed

+21
-14
lines changed

2 files changed

+21
-14
lines changed

mapswipe_workers/basic/BaseProject.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,10 @@ def set_groups_progress_postgres(self, postgres, groups_progress_list):
187187
{} as b
188188
WHERE
189189
groups.group_id = b.group_id
190-
and groups.project_id = b.project_id;
190+
and
191+
groups.project_id = b.project_id
192+
and
193+
groups.completedcount =! b.completedcount;
191194
DROP TABLE IF EXISTS {};
192195
'''
193196
sql_insert = sql.SQL(sql_insert).format(sql.Identifier(groups_progress_tablename),

tests/test_terminate.py

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,23 @@ def delete_sample_data_from_firebase(firebase, project_id, import_key):
2222
# get all results from firebase
2323
all_results = fb_db.child("results").get().val()
2424

25-
data = {}
26-
for task_id, results in all_results.items():
27-
for child_id, result in results.items():
28-
29-
if result['data']['projectId'] == project_id:
30-
key = 'results/{task_id}/{child_id}'.format(
31-
task_id=task_id,
32-
child_id=child_id)
33-
34-
data[key] = None
35-
36-
fb_db.update(data)
37-
print('deleted all results for project %s' % project_id)
25+
if not all_results:
26+
print('there are no results in firebase')
27+
pass
28+
else:
29+
data = {}
30+
for task_id, results in all_results.items():
31+
for child_id, result in results.items():
32+
33+
if result['data']['projectId'] == project_id:
34+
key = 'results/{task_id}/{child_id}'.format(
35+
task_id=task_id,
36+
child_id=child_id)
37+
38+
data[key] = None
39+
40+
fb_db.update(data)
41+
print('deleted all results for project %s' % project_id)
3842

3943

4044

0 commit comments

Comments
 (0)