From 1af84c1231ceb4ec2ad9a891e3901e85fd022131 Mon Sep 17 00:00:00 2001 From: Mateusz Mandera Date: Fri, 20 Oct 2023 02:16:38 +0200 Subject: [PATCH] zilencer: Extract BaseRemoteCount class. --- zilencer/models.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/zilencer/models.py b/zilencer/models.py index f2571039f3..9b69107b08 100644 --- a/zilencer/models.py +++ b/zilencer/models.py @@ -130,11 +130,16 @@ class RemoteRealmAuditLog(AbstractRealmAuditLog): ] -class RemoteInstallationCount(BaseCount): +class BaseRemoteCount(BaseCount): server = models.ForeignKey(RemoteZulipServer, on_delete=models.CASCADE) # The remote_id field lets us deduplicate data from the remote server remote_id = models.IntegerField() + class Meta: + abstract = True + + +class RemoteInstallationCount(BaseRemoteCount): class Meta: unique_together = ("server", "property", "subgroup", "end_time") indexes = [ @@ -150,11 +155,8 @@ class RemoteInstallationCount(BaseCount): # We can't subclass RealmCount because we only have a realm_id here, not a foreign key. -class RemoteRealmCount(BaseCount): - server = models.ForeignKey(RemoteZulipServer, on_delete=models.CASCADE) +class RemoteRealmCount(BaseRemoteCount): realm_id = models.IntegerField() - # The remote_id field lets us deduplicate data from the remote server - remote_id = models.IntegerField() class Meta: unique_together = ("server", "realm_id", "property", "subgroup", "end_time")