zilencer: Extract BaseRemoteCount class.

This commit is contained in:
Mateusz Mandera 2023-10-20 02:16:38 +02:00 committed by Tim Abbott
parent 3cbb651942
commit 1af84c1231
1 changed files with 7 additions and 5 deletions

View File

@ -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")