Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
update_subscriber_counts: Fix union typing.
Anders Kaseorg7f3bb4523c89
diff --git a/zerver/management/commands/update_subscriber_counts.py b/zerver/management/commands/update_subscriber_counts.pyindex 2ca11a6843b..6bd3518eee5 100644--- a/zerver/management/commands/update_subscriber_counts.py+++ b/zerver/management/commands/update_subscriber_counts.py@@ -5,7 +5,7 @@ from typing import Anyfrom django.conf import settingsfrom django.db import transaction-from django.db.models import QuerySet+from django.db.models import F, QuerySetfrom django.utils.timezone import now as timezone_nowfrom typing_extensions import override@@ -85,10 +85,12 @@ accurate; this command is run as a daily cron job to ensure the number is accurastreams_from_users = streams_from_users.filter(realm=realm)stream_ids: QuerySet[Any, int] = (- changed_subs.values_list("modified_stream_id", flat=True)- .distinct()+ changed_subs.distinct("modified_stream_id").order_by("modified_stream_id")- ).union(streams_from_users.values_list("id", flat=True))+ .annotate(stream_id=F("modified_stream_id"))+ .union(streams_from_users.annotate(stream_id="id"))+ .values_list("stream_id", flat=True)+ )elif realm := self.get_realm(options):stream_ids = streams.filter(realm=realm).values_list("id", flat=True)else: