zilencer: Clean up realms return structure.

It seems most correct to answer the question about whether push
notifications are working specifically for the exact set of realms
that the server self-reported to us in fact exist.

Sending data on any additional realms that were not referenced in the
request (if that's somehow possible without them being locally
deleted) is likely to only be confusing.

And the client should reasonably be able to expect to get a response
covering exactly the realms it told us about.
This commit is contained in:
Tim Abbott 2024-01-04 17:57:24 -08:00
parent 2436df6fa6
commit 41eb6d947c
1 changed files with 10 additions and 4 deletions

View File

@ -1092,10 +1092,16 @@ def remote_server_post_analytics(
assert log_data is not None assert log_data is not None
can_push_values = set() can_push_values = set()
remote_realms = RemoteRealm.objects.filter(server=server, realm_locally_deleted=False) # Return details on exactly the set of remote realm the client told us about.
remote_realm_dict: Dict[str, RemoteRealmDictValue] = {} remote_realm_dict: Dict[str, RemoteRealmDictValue] = {}
remote_human_realm_count = remote_realms.filter(is_system_bot_realm=False).count() remote_human_realm_count = len(
for remote_realm in remote_realms: [
remote_realm
for remote_realm in realm_id_to_remote_realm.values()
if not remote_realm.is_system_bot_realm
]
)
for remote_realm in realm_id_to_remote_realm.values():
uuid = str(remote_realm.uuid) uuid = str(remote_realm.uuid)
status = get_push_status_for_remote_request(server, remote_realm) status = get_push_status_for_remote_request(server, remote_realm)
if remote_realm.is_system_bot_realm: if remote_realm.is_system_bot_realm:
@ -1122,7 +1128,7 @@ def remote_server_post_analytics(
def build_realm_id_to_remote_realm_dict( def build_realm_id_to_remote_realm_dict(
server: RemoteZulipServer, realms: Optional[List[RealmDataForAnalytics]] server: RemoteZulipServer, realms: Optional[List[RealmDataForAnalytics]]
) -> Dict[int, Optional[RemoteRealm]]: ) -> Dict[int, RemoteRealm]:
if realms is None: if realms is None:
return {} return {}