mirror of https://github.com/zulip/zulip.git
zilencer: Store the last-reported server version when storing analytics.
Servers since 216d2ec1bf
(version 2.0.0)
have submitted this, but we have never stored it.
This commit is contained in:
parent
d404febb29
commit
9bc41ca040
|
@ -952,9 +952,19 @@ class AnalyticsBouncerTest(BouncerTestCase):
|
||||||
audit_log = RealmAuditLog.objects.all().order_by("id").last()
|
audit_log = RealmAuditLog.objects.all().order_by("id").last()
|
||||||
assert audit_log is not None
|
assert audit_log is not None
|
||||||
audit_log_max_id = audit_log.id
|
audit_log_max_id = audit_log.id
|
||||||
|
|
||||||
|
remote_server = RemoteZulipServer.objects.get(uuid=self.server_uuid)
|
||||||
|
assert remote_server is not None
|
||||||
|
assert remote_server.last_version is None
|
||||||
|
|
||||||
send_analytics_to_push_bouncer()
|
send_analytics_to_push_bouncer()
|
||||||
self.assertTrue(responses.assert_call_count(ANALYTICS_STATUS_URL, 1))
|
self.assertTrue(responses.assert_call_count(ANALYTICS_STATUS_URL, 1))
|
||||||
|
|
||||||
|
remote_server = RemoteZulipServer.objects.get(uuid=self.server_uuid)
|
||||||
|
assert remote_server.last_version == ZULIP_VERSION
|
||||||
|
|
||||||
remote_audit_log_count = RemoteRealmAuditLog.objects.count()
|
remote_audit_log_count = RemoteRealmAuditLog.objects.count()
|
||||||
|
|
||||||
self.assertEqual(RemoteRealmCount.objects.count(), 0)
|
self.assertEqual(RemoteRealmCount.objects.count(), 0)
|
||||||
self.assertEqual(RemoteInstallationCount.objects.count(), 0)
|
self.assertEqual(RemoteInstallationCount.objects.count(), 0)
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
# Generated by Django 4.2.7 on 2023-11-17 20:59
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
dependencies = [
|
||||||
|
("zilencer", "0035_remoterealmcount_remote_realm_and_more"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name="remotezulipserver",
|
||||||
|
name="last_version",
|
||||||
|
field=models.CharField(max_length=128, null=True),
|
||||||
|
),
|
||||||
|
]
|
|
@ -30,6 +30,7 @@ class RemoteZulipServer(models.Model):
|
||||||
UUID_LENGTH = 36
|
UUID_LENGTH = 36
|
||||||
API_KEY_LENGTH = 64
|
API_KEY_LENGTH = 64
|
||||||
HOSTNAME_MAX_LENGTH = 128
|
HOSTNAME_MAX_LENGTH = 128
|
||||||
|
VERSION_MAX_LENGTH = 128
|
||||||
|
|
||||||
# The unique UUID (`zulip_org_id`) and API key (`zulip_org_key`)
|
# The unique UUID (`zulip_org_id`) and API key (`zulip_org_key`)
|
||||||
# for this remote server registration.
|
# for this remote server registration.
|
||||||
|
@ -42,6 +43,7 @@ class RemoteZulipServer(models.Model):
|
||||||
hostname = models.CharField(max_length=HOSTNAME_MAX_LENGTH)
|
hostname = models.CharField(max_length=HOSTNAME_MAX_LENGTH)
|
||||||
contact_email = models.EmailField(blank=True, null=False)
|
contact_email = models.EmailField(blank=True, null=False)
|
||||||
last_updated = models.DateTimeField("last updated", auto_now=True)
|
last_updated = models.DateTimeField("last updated", auto_now=True)
|
||||||
|
last_version = models.CharField(max_length=VERSION_MAX_LENGTH, null=True)
|
||||||
|
|
||||||
# Whether the server registration has been deactivated.
|
# Whether the server registration has been deactivated.
|
||||||
deactivated = models.BooleanField(default=False)
|
deactivated = models.BooleanField(default=False)
|
||||||
|
|
|
@ -625,13 +625,21 @@ def remote_server_post_analytics(
|
||||||
installation_counts: Json[List[InstallationCountDataForAnalytics]],
|
installation_counts: Json[List[InstallationCountDataForAnalytics]],
|
||||||
realmauditlog_rows: Optional[Json[List[RealmAuditLogDataForAnalytics]]] = None,
|
realmauditlog_rows: Optional[Json[List[RealmAuditLogDataForAnalytics]]] = None,
|
||||||
realms: Optional[Json[List[RealmDataForAnalytics]]] = None,
|
realms: Optional[Json[List[RealmDataForAnalytics]]] = None,
|
||||||
|
version: Optional[Json[str]] = None,
|
||||||
) -> HttpResponse:
|
) -> HttpResponse:
|
||||||
|
if version is not None:
|
||||||
|
version = version[0 : RemoteZulipServer.VERSION_MAX_LENGTH]
|
||||||
|
if version != server.last_version:
|
||||||
|
server.last_version = version
|
||||||
|
server.save(update_fields=["last_version"])
|
||||||
|
|
||||||
validate_incoming_table_data(
|
validate_incoming_table_data(
|
||||||
server, RemoteRealmCount, [dict(count) for count in realm_counts], True
|
server, RemoteRealmCount, [dict(count) for count in realm_counts], True
|
||||||
)
|
)
|
||||||
validate_incoming_table_data(
|
validate_incoming_table_data(
|
||||||
server, RemoteInstallationCount, [dict(count) for count in installation_counts], True
|
server, RemoteInstallationCount, [dict(count) for count in installation_counts], True
|
||||||
)
|
)
|
||||||
|
|
||||||
if realmauditlog_rows is not None:
|
if realmauditlog_rows is not None:
|
||||||
validate_incoming_table_data(
|
validate_incoming_table_data(
|
||||||
server, RemoteRealmAuditLog, [dict(row) for row in realmauditlog_rows]
|
server, RemoteRealmAuditLog, [dict(row) for row in realmauditlog_rows]
|
||||||
|
|
Loading…
Reference in New Issue