Skip to content

Commit

Permalink
feat: add computation of "not opened" on dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
dodumosu committed Aug 8, 2021
1 parent 0edb13c commit f915254
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions apollo/frontend/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,20 @@ def _get_group_coverage(query, form, group, location_type):
else:
offline_query = query.filter(false())

if group_tags:
not_opened_query = query.filter(
and_(
Submission.not_opened == True, # noqa
not_(
and_(
Submission.data.has_all(array(group_tags)),
Submission.not_opened == True
)
)
))
else:
not_opened_query = query.filter(false())

dataset = defaultdict(dict)

for loc_id, loc_name, count in _get_coverage_results(
Expand Down Expand Up @@ -178,13 +192,22 @@ def _get_group_coverage(query, form, group, location_type):
'name': loc_name
})

for loc_id, loc_name, count in _get_coverage_results(
not_opened_query, depth_info.depth):
dataset[loc_name].update({
'Closed': count,
'id': loc_id,
'name': loc_name
})

for name in sorted(dataset.keys()):
loc_data = dataset.get(name)
loc_data.setdefault('Complete', 0)
loc_data.setdefault('Conflict', 0)
loc_data.setdefault('Missing', 0)
loc_data.setdefault('Partial', 0)
loc_data.setdefault('Offline', 0)
loc_data.setdefault('Closed', 0)

coverage_list.append(loc_data)

Expand Down Expand Up @@ -257,12 +280,27 @@ def _get_global_coverage(query, form):
else:
offline_query = query.filter(false())

if group_tags:
not_opened_query = query.filter(
and_(
Submission.not_opened == True, # noqa
not_(
and_(
Submission.data.has_all(array(group_tags)),
Submission.not_opened == True
)
)
))
else:
not_opened_query = query.filter(false())

data = {
'Complete': complete_query.count(),
'Conflict': conflict_query.count(),
'Missing': missing_query.count(),
'Partial': partial_query.count(),
'Offline': offline_query.count(),
'Closed': not_opened_query.count(),
'name': group['name'],
'slug': group['slug']
}
Expand Down

0 comments on commit f915254

Please sign in to comment.