Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions api/subscriptions/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ def get_queryset(self):
notification_type__name__in=_global_reviews,
then=Value('global_reviews'),
),
default=Value('notification_type__name'),
),
legacy_id=Case(
When(
Expand All @@ -113,6 +114,7 @@ def get_queryset(self):
notification_type__name__in=_global_reviews,
then=Value(f'{user_guid}_global_reviews'),
),
default=Value('notification_type__name'),
),
).distinct('legacy_id')

Expand All @@ -121,6 +123,10 @@ def get_queryset(self):
if filter_id:
qs = qs.filter(legacy_id=filter_id)
# convert to list comprehension because legacy_id is an annotation, not in DB
# Apply manual filter for event_name if requested
filter_event_name = self.request.query_params.get('filter[event_name]')
if filter_event_name:
qs = qs.filter(event_name__in=filter_event_name.split(','))

return qs

Expand Down
2 changes: 1 addition & 1 deletion api_tests/subscriptions/views/test_subscriptions_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def test_cannot_post_patch_put_or_delete(self, app, url, user):
assert delete_res.status_code == 405

def test_multiple_values_filter(self, app, url, user):
res = app.get(url + '?filter[event_name]=comments,file_updated', auth=user.auth)
res = app.get(url + '?filter[event_name]=global_file_updated,files_updated', auth=user.auth)
assert len(res.json['data']) == 2
for subscription in res.json['data']:
subscription['attributes']['event_name'] in ['global', 'comments']
Expand Down
Loading