counts: Add new mobile_pushes RemoteRealmCount stats.

This requires a bit of complexity to avoid a name collision in
COUNT_STATS with the RemoteInstallationCount stats with the same name.
This commit is contained in:
Mateusz Mandera
2023-11-09 19:24:49 +01:00
committed by Tim Abbott
parent 2512e66c06
commit 48db4bf854
10 changed files with 293 additions and 29 deletions

View File

@@ -200,7 +200,14 @@ class RemoteInstallationCount(BaseRemoteCount):
# We can't subclass RealmCount because we only have a realm_id here, not a foreign key.
class RemoteRealmCount(BaseRemoteCount):
realm_id = models.IntegerField()
realm_id = models.IntegerField(null=True)
# Certain RemoteRealmCount will be counts tracked on the bouncer server directly, about
# stats pertaining to a realm on a remote server. For such objects, we will link to
# the corresponding RemoteRealm object that the remote server registered with us.
# In the future we may be able to link all RemoteRealmCount objects to a RemoteRealm,
# including the RemoteRealmCount objects are results of just syncing the RealmCount
# table from the remote server.
remote_realm = models.ForeignKey(RemoteRealm, on_delete=models.CASCADE, null=True)
class Meta:
unique_together = ("server", "realm_id", "property", "subgroup", "end_time")