statistics: always allow group by channel (#85530)
gitea/wcs/pipeline/head This commit looks good
Details
gitea/wcs/pipeline/head This commit looks good
Details
This commit is contained in:
parent
f39f15f2b6
commit
e7f9a625df
|
@ -991,6 +991,10 @@ def test_statistics_forms_count_group_by(pub, formdef, anonymise):
|
|||
{'data': [6, None, None], 'label': 'Backoffice'},
|
||||
]
|
||||
|
||||
# group by channel without form filter
|
||||
new_resp = get_app(pub).get(sign_uri('/api/statistics/forms/count/?group-by=channel'))
|
||||
assert new_resp.json['data']['series'] == resp.json['data']['series']
|
||||
|
||||
# group by item field without time interval
|
||||
resp = get_app(pub).get(sign_uri(url + '&group-by=test-item&time_interval=none'))
|
||||
# Foo is first because it has a display value, baz is second because it has not, None is always last
|
||||
|
@ -1100,7 +1104,10 @@ def test_statistics_forms_count_group_by_form(pub):
|
|||
assert resp.json['data']['subfilters'][1] == {
|
||||
'id': 'group-by',
|
||||
'label': 'Group by',
|
||||
'options': [{'id': 'form', 'label': 'Form'}],
|
||||
'options': [
|
||||
{'id': 'channel', 'label': 'Channel'},
|
||||
{'id': 'form', 'label': 'Form'},
|
||||
],
|
||||
'has_subfilters': True,
|
||||
}
|
||||
|
||||
|
@ -1726,8 +1733,8 @@ def test_statistics_multiple_forms_count_subfilters(pub, formdef):
|
|||
# group-by subfilter shows all common fields
|
||||
group_by_filter = [x for x in resp.json['data']['subfilters'] if x['id'] == 'group-by'][0]
|
||||
assert group_by_filter['options'] == [
|
||||
{'id': 'form', 'label': 'Form'},
|
||||
{'id': 'channel', 'label': 'Channel'},
|
||||
{'id': 'form', 'label': 'Form'},
|
||||
{'id': 'simple-status', 'label': 'Simplified status'},
|
||||
{'id': 'test-item', 'label': 'Test item'},
|
||||
{'id': 'checkbox', 'label': 'Checkbox'},
|
||||
|
|
|
@ -383,7 +383,9 @@ class FormsCountView(RestrictedView):
|
|||
'id': 'group-by',
|
||||
'label': _('Group by'),
|
||||
'has_subfilters': True,
|
||||
'options': [],
|
||||
'options': [
|
||||
{'id': 'channel', 'label': _('Channel')},
|
||||
],
|
||||
}
|
||||
|
||||
if len(formdefs) != 1:
|
||||
|
@ -430,12 +432,9 @@ class FormsCountView(RestrictedView):
|
|||
subfilter['options'].sort(key=lambda x: x['label'])
|
||||
|
||||
group_by_filter = [x for x in common_subfilters if x['id'] == 'group-by'][0]
|
||||
group_by_filter['options'].append({'id': 'simple-status', 'label': _('Simplified status')})
|
||||
group_by_filter['options'].extend(
|
||||
[
|
||||
{'id': 'channel', 'label': _('Channel')},
|
||||
{'id': 'simple-status', 'label': _('Simplified status')},
|
||||
]
|
||||
+ [{'id': x['id'].removeprefix('filter-'), 'label': x['label']} for x in subfilters]
|
||||
[{'id': x['id'].removeprefix('filter-'), 'label': x['label']} for x in subfilters]
|
||||
)
|
||||
|
||||
if group_by not in (None, 'channel', 'simple-status', 'status'):
|
||||
|
|
Loading…
Reference in New Issue