From 8695ffba490e889f9ca6a3f6b9c3bbc890373a2b Mon Sep 17 00:00:00 2001 From: Mateusz Mandera Date: Wed, 22 Nov 2023 18:22:22 +0100 Subject: [PATCH] remote_server_post_analytics: Change RealmDataForAnalytics.uuid type. pydantic allows us to use UUID4 as a more accurate type. --- zerver/lib/remote_server.py | 6 +++--- zilencer/views.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/zerver/lib/remote_server.py b/zerver/lib/remote_server.py index f5c5c40697..6b852d4991 100644 --- a/zerver/lib/remote_server.py +++ b/zerver/lib/remote_server.py @@ -7,7 +7,7 @@ import requests from django.conf import settings from django.forms.models import model_to_dict from django.utils.translation import gettext as _ -from pydantic import BaseModel, ConfigDict +from pydantic import UUID4, BaseModel, ConfigDict from analytics.models import InstallationCount, RealmCount from version import ZULIP_VERSION @@ -39,7 +39,7 @@ class RealmDataForAnalytics(BaseModel): date_created: float deactivated: bool - uuid: str + uuid: UUID4 uuid_owner_secret: str @@ -191,7 +191,7 @@ def get_realms_info_for_push_bouncer() -> List[RealmDataForAnalytics]: realm_info_list = [ RealmDataForAnalytics( id=realm.id, - uuid=str(realm.uuid), + uuid=realm.uuid, uuid_owner_secret=realm.uuid_owner_secret, host=realm.host, url=realm.uri, diff --git a/zilencer/views.py b/zilencer/views.py index 8a6ddd1efd..01a3b4b832 100644 --- a/zilencer/views.py +++ b/zilencer/views.py @@ -531,7 +531,7 @@ def update_remote_realm_data_for_server( uuids = [realm["uuid"] for realm in server_realms_info] already_registered_remote_realms = RemoteRealm.objects.filter(uuid__in=uuids, server=server) already_registered_uuids = { - str(remote_realm.uuid) for remote_realm in already_registered_remote_realms + remote_realm.uuid for remote_realm in already_registered_remote_realms } new_remote_realms = [