subs: Allow filtering by is_user_active in get_active_subscriptions.

get_active_subscriptions_for_stream_id should allow specifying whether
subscriptions of deactivated users should be included in the result.
Active subs of deactivated users are  a subtlety that's easy to miss
when writing relevant code, so we make include_deactivated_users a
mandatory kwarg - this will force callers to definitely give thought to
whether such subs should be included or not.

This commit is just a refactoring, we keep original behavior everywhere
- there are places where subs of deactivates users should probably be
excluded but aren't - we don't fix that here, it'll be addressed in
follow-up commits.
This commit is contained in:
Mateusz Mandera
2021-04-17 13:29:55 +02:00
committed by Tim Abbott
parent efc63ae7ce
commit 50bfbb588e
4 changed files with 48 additions and 39 deletions

View File

@@ -28,4 +28,6 @@ class StreamTopicTarget:
return {row["user_profile_id"] for row in query}
def get_active_subscriptions(self) -> QuerySet:
return get_active_subscriptions_for_stream_id(self.stream_id)
return get_active_subscriptions_for_stream_id(
self.stream_id, include_deactivated_users=True
)