mirror of
https://github.com/zulip/zulip.git
synced 2025-10-24 08:33:43 +00:00
update_subscriber_counts: Fix calling without any flags.
This commit is contained in:
committed by
Tim Abbott
parent
c7810afb33
commit
8c37e9c7a6
@@ -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:
|
def handle(self, *args: Any, **options: Any) -> None:
|
||||||
realm = self.get_realm(options)
|
realm = self.get_realm(options)
|
||||||
streams = Stream.objects.all()
|
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"]:
|
if options["since"]:
|
||||||
since_time = timezone_now() - timedelta(hours=options["since"])
|
since_time = timezone_now() - timedelta(hours=options["since"])
|
||||||
# Two ways the count can change -- via a subscription
|
# 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:
|
if realm:
|
||||||
streams_from_users = streams_from_users.filter(realm=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)
|
changed_subs.values_list("modified_stream_id", flat=True)
|
||||||
.distinct()
|
.distinct()
|
||||||
.order_by("modified_stream_id")
|
.order_by("modified_stream_id")
|
||||||
).union(streams_from_users.values_list("id", flat=True))
|
).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():
|
for stream_id in stream_ids.iterator():
|
||||||
with transaction.atomic(durable=True):
|
with transaction.atomic(durable=True):
|
||||||
|
|||||||
Reference in New Issue
Block a user