From a1d1be419f9242b0f49ed851b45560e6a198964a Mon Sep 17 00:00:00 2001 From: Ostap Zherebetskyi Date: Mon, 1 Dec 2025 18:31:51 +0200 Subject: [PATCH 1/2] add manual filtering for event_name in subscription list --- api/subscriptions/views.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/api/subscriptions/views.py b/api/subscriptions/views.py index d7dfb944ecb..b03cd7eb73e 100644 --- a/api/subscriptions/views.py +++ b/api/subscriptions/views.py @@ -121,6 +121,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 From c9d71d7e786806817d89471c919044dde5f64ebb Mon Sep 17 00:00:00 2001 From: Ostap Zherebetskyi Date: Mon, 1 Dec 2025 18:59:28 +0200 Subject: [PATCH 2/2] fix unit tests --- api/subscriptions/views.py | 2 ++ api_tests/subscriptions/views/test_subscriptions_list.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/api/subscriptions/views.py b/api/subscriptions/views.py index b03cd7eb73e..8c5f67b74e6 100644 --- a/api/subscriptions/views.py +++ b/api/subscriptions/views.py @@ -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( @@ -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') diff --git a/api_tests/subscriptions/views/test_subscriptions_list.py b/api_tests/subscriptions/views/test_subscriptions_list.py index c376e260014..599df9ddcd6 100644 --- a/api_tests/subscriptions/views/test_subscriptions_list.py +++ b/api_tests/subscriptions/views/test_subscriptions_list.py @@ -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']