Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

update_subscriber_counts: Fix calling without any flags.

Alex Vandiver8c37e9c7a6fa
diff --git a/zerver/management/commands/update_subscriber_counts.py b/zerver/management/commands/update_subscriber_counts.py
index e3a036ae5ea..2ca11a6843b 100644
--- a/zerver/management/commands/update_subscriber_counts.py
+++ b/zerver/management/commands/update_subscriber_counts.py
@@ -39,10 +39,6 @@ accurate; this command is run as a daily cron job to ensure the number is accura
def handle(self, *args: Any, **options: Any) -> None:
realm = self.get_realm(options)
streams = Stream.objects.all()
- if realm := self.get_realm(options):
- stream_ids: QuerySet[Any, int] = streams.filter(realm=realm).values_list(
- "id", flat=True
- )
if options["since"]:
since_time = timezone_now() - timedelta(hours=options["since"])
# Two ways the count can change -- via a subscription
@@ -88,11 +84,15 @@ accurate; this command is run as a daily cron job to ensure the number is accura
if realm:
streams_from_users = streams_from_users.filter(realm=realm)
- stream_ids = (
+ stream_ids: QuerySet[Any, int] = (
changed_subs.values_list("modified_stream_id", flat=True)
.distinct()
.order_by("modified_stream_id")
).union(streams_from_users.values_list("id", flat=True))
+ elif realm := self.get_realm(options):
+ stream_ids = streams.filter(realm=realm).values_list("id", flat=True)
+ else:
+ stream_ids = streams.all().values_list("id", flat=True)
for stream_id in stream_ids.iterator():
with transaction.atomic(durable=True):