mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 13:33:24 +00:00
analytics: Remove Anomaly model.
This commit is contained in:
@@ -9,7 +9,7 @@ from django.conf import settings
|
||||
from django.db import connection, models
|
||||
from django.db.models import F
|
||||
|
||||
from analytics.models import Anomaly, BaseCount, \
|
||||
from analytics.models import BaseCount, \
|
||||
FillState, InstallationCount, RealmCount, StreamCount, \
|
||||
UserCount, installation_epoch, last_successful_fill
|
||||
from zerver.lib.logging_util import log_to_file
|
||||
@@ -226,7 +226,6 @@ def do_drop_all_analytics_tables() -> None:
|
||||
RealmCount.objects.all().delete()
|
||||
InstallationCount.objects.all().delete()
|
||||
FillState.objects.all().delete()
|
||||
Anomaly.objects.all().delete()
|
||||
|
||||
def do_drop_single_stat(property: str) -> None:
|
||||
UserCount.objects.filter(property=property).delete()
|
||||
|
||||
34
analytics/migrations/0013_remove_anomaly.py
Normal file
34
analytics/migrations/0013_remove_anomaly.py
Normal file
@@ -0,0 +1,34 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.18 on 2019-02-02 02:47
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('analytics', '0012_add_on_delete'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name='installationcount',
|
||||
name='anomaly',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='realmcount',
|
||||
name='anomaly',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='streamcount',
|
||||
name='anomaly',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='usercount',
|
||||
name='anomaly',
|
||||
),
|
||||
migrations.DeleteModel(
|
||||
name='Anomaly',
|
||||
),
|
||||
]
|
||||
@@ -34,13 +34,6 @@ def last_successful_fill(property: str) -> Optional[datetime.datetime]:
|
||||
return fillstate.end_time
|
||||
return fillstate.end_time - datetime.timedelta(hours=1)
|
||||
|
||||
# would only ever make entries here by hand
|
||||
class Anomaly(models.Model):
|
||||
info = models.CharField(max_length=1000) # type: str
|
||||
|
||||
def __str__(self) -> str:
|
||||
return "<Anomaly: %s... %s>" % (self.info, self.id)
|
||||
|
||||
class BaseCount(models.Model):
|
||||
# Note: When inheriting from BaseCount, you may want to rearrange
|
||||
# the order of the columns in the migration to make sure they
|
||||
@@ -49,7 +42,6 @@ class BaseCount(models.Model):
|
||||
subgroup = models.CharField(max_length=16, null=True) # type: Optional[str]
|
||||
end_time = models.DateTimeField() # type: datetime.datetime
|
||||
value = models.BigIntegerField() # type: int
|
||||
anomaly = models.ForeignKey(Anomaly, on_delete=models.SET_NULL, null=True) # type: Optional[Anomaly]
|
||||
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
||||
@@ -15,7 +15,7 @@ from analytics.lib.counts import COUNT_STATS, CountStat, DataCollector, \
|
||||
do_drop_all_analytics_tables, do_drop_single_stat, \
|
||||
do_fill_count_stat_at_hour, do_increment_logging_stat, \
|
||||
process_count_stat, sql_data_collector
|
||||
from analytics.models import Anomaly, BaseCount, \
|
||||
from analytics.models import BaseCount, \
|
||||
FillState, InstallationCount, RealmCount, StreamCount, \
|
||||
UserCount, installation_epoch, last_successful_fill
|
||||
from zerver.lib.actions import do_activate_user, do_create_user, \
|
||||
@@ -846,7 +846,6 @@ class TestDeleteStats(AnalyticsTestCase):
|
||||
RealmCount.objects.create(realm=user.realm, **count_args)
|
||||
InstallationCount.objects.create(**count_args)
|
||||
FillState.objects.create(property='test', end_time=self.TIME_ZERO, state=FillState.DONE)
|
||||
Anomaly.objects.create(info='test anomaly')
|
||||
|
||||
analytics = apps.get_app_config('analytics')
|
||||
for table in list(analytics.models.values()):
|
||||
@@ -869,7 +868,6 @@ class TestDeleteStats(AnalyticsTestCase):
|
||||
InstallationCount.objects.create(**count_args)
|
||||
FillState.objects.create(property='to_delete', end_time=self.TIME_ZERO, state=FillState.DONE)
|
||||
FillState.objects.create(property='to_save', end_time=self.TIME_ZERO, state=FillState.DONE)
|
||||
Anomaly.objects.create(info='test anomaly')
|
||||
|
||||
analytics = apps.get_app_config('analytics')
|
||||
for table in list(analytics.models.values()):
|
||||
@@ -877,9 +875,6 @@ class TestDeleteStats(AnalyticsTestCase):
|
||||
|
||||
do_drop_single_stat('to_delete')
|
||||
for table in list(analytics.models.values()):
|
||||
if table._meta.db_table == 'analytics_anomaly':
|
||||
self.assertTrue(table.objects.exists())
|
||||
else:
|
||||
self.assertFalse(table.objects.filter(property='to_delete').exists())
|
||||
self.assertTrue(table.objects.filter(property='to_save').exists())
|
||||
|
||||
|
||||
@@ -51,8 +51,6 @@ set of database tables. Each of these tables has the following fields:
|
||||
"messages_sent:client:day" in the UserCount table, this is the number of
|
||||
messages sent by a particular user, from a particular client, on the day
|
||||
ending at end_time.
|
||||
- anomaly: Currently unused, but a key into the Anomaly table allowing
|
||||
someone to indicate a data irregularity.
|
||||
|
||||
There are four tables: UserCount, StreamCount, RealmCount, and
|
||||
InstallationCount. Every CountStat is initially collected into UserCount,
|
||||
|
||||
@@ -57,7 +57,6 @@ MessageOutput = Dict[str, Union[List[Record], List[int], int]]
|
||||
MESSAGE_BATCH_CHUNK_SIZE = 1000
|
||||
|
||||
ALL_ZULIP_TABLES = {
|
||||
'analytics_anomaly',
|
||||
'analytics_fillstate',
|
||||
'analytics_installationcount',
|
||||
'analytics_realmcount',
|
||||
@@ -174,8 +173,6 @@ NON_EXPORTED_TABLES = {
|
||||
|
||||
# Fillstate will require some cleverness to do the right partial export.
|
||||
'analytics_fillstate',
|
||||
# This table isn't yet used for anything.
|
||||
'analytics_anomaly',
|
||||
|
||||
# These are for unfinished features; we'll want to add them ot the
|
||||
# export before they reach full production status.
|
||||
|
||||
Reference in New Issue
Block a user