diff --git a/analytics/lib/counts.py b/analytics/lib/counts.py index 090d6433e8..1c965523da 100644 --- a/analytics/lib/counts.py +++ b/analytics/lib/counts.py @@ -2,7 +2,7 @@ from django.db import connection, models from datetime import timedelta, datetime from analytics.models import InstallationCount, RealmCount, \ - UserCount, StreamCount, HuddleCount, BaseCount + UserCount, StreamCount, BaseCount from analytics.lib.interval import TimeInterval, timeinterval_range, subintervals from zerver.models import Realm, UserProfile, Message, Stream, models @@ -237,25 +237,6 @@ count_stream_by_realm_query = """ """ zerver_count_stream_by_realm = ZerverCountQuery(Stream, RealmCount, count_stream_by_realm_query) -count_message_by_huddle_query = """ - INSERT INTO analytics_huddlecount - (huddle_id, user_id, value, property, end_time, interval) - SELECT - zerver_message.recipient_id, zerver_message.sender_id, count(*), '%(property)s', %%(time_end)s, '%(interval)s' - FROM zerver_message - INNER JOIN zerver_recipient - ON - ( - zerver_recipient.type = 3 AND - zerver_message.recipient_id = zerver_recipient.id AND - zerver_message.pub_date >= %%(time_start)s AND - zerver_message.pub_date < %%(time_end)s - %(join_args)s - ) - GROUP BY zerver_message.recipient_id, zerver_message.sender_id -""" -zerver_count_message_by_huddle = ZerverCountQuery(Message, HuddleCount, count_message_by_huddle_query) - COUNT_STATS = { 'active_humans': CountStat('active_humans', zerver_count_user_by_realm, {'is_bot': False, 'is_active': True}, 'gauge', 'day'), diff --git a/analytics/management/commands/clear_analytics_tables.py b/analytics/management/commands/clear_analytics_tables.py index 0e150352e7..c512eea32d 100644 --- a/analytics/management/commands/clear_analytics_tables.py +++ b/analytics/management/commands/clear_analytics_tables.py @@ -14,7 +14,6 @@ DELETE FROM ONLY analytics_installationcount; DELETE FROM ONLY analytics_realmcount; DELETE FROM ONLY analytics_usercount; DELETE FROM ONLY analytics_streamcount; -DELETE FROM ONLY analytics_huddlecount """ class Command(BaseCommand): @@ -35,4 +34,3 @@ class Command(BaseCommand): else: print("Would delete all data from analytics tables (!); use --force to do so.") sys.exit(1) - diff --git a/analytics/migrations/0002_remove_huddlecount.py b/analytics/migrations/0002_remove_huddlecount.py new file mode 100644 index 0000000000..fa141b0e6f --- /dev/null +++ b/analytics/migrations/0002_remove_huddlecount.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('analytics', '0001_initial'), + ] + + operations = [ + migrations.AlterUniqueTogether( + name='huddlecount', + unique_together=set([]), + ), + migrations.RemoveField( + model_name='huddlecount', + name='anomaly', + ), + migrations.RemoveField( + model_name='huddlecount', + name='huddle', + ), + migrations.RemoveField( + model_name='huddlecount', + name='user', + ), + migrations.DeleteModel( + name='HuddleCount', + ), + ] diff --git a/analytics/models.py b/analytics/models.py index 7bded272f0..be72dfa7ec 100644 --- a/analytics/models.py +++ b/analytics/models.py @@ -120,24 +120,3 @@ class StreamCount(BaseCount): def __unicode__(self): # type: () -> text_type return u"" % (self.stream, self.property, self.value, self.id) - -class HuddleCount(BaseCount): - huddle = models.ForeignKey(Recipient) - user = models.ForeignKey(UserProfile) - - class Meta(object): - unique_together = ("huddle", "property", "end_time", "interval") - - @staticmethod - def extended_id(): - # type: () -> Tuple[str, ...] - return ('huddle_id', 'user_id') - - @staticmethod - def key_model(): - # type: () -> models.Model - return Recipient - - def __unicode__(self): - # type: () -> text_type - return u"" % (self.huddle, self.property, self.value, self.id) diff --git a/analytics/tests/test_counts.py b/analytics/tests/test_counts.py index 67da829993..ab58e494e8 100644 --- a/analytics/tests/test_counts.py +++ b/analytics/tests/test_counts.py @@ -5,8 +5,7 @@ from django.utils import timezone from analytics.lib.interval import TimeInterval from analytics.lib.counts import CountStat, COUNT_STATS, process_count_stat, \ zerver_count_user_by_realm, zerver_count_message_by_user, \ - zerver_count_message_by_stream, zerver_count_stream_by_realm, \ - zerver_count_message_by_huddle + zerver_count_message_by_stream, zerver_count_stream_by_realm from analytics.models import BaseCount, InstallationCount, RealmCount, \ UserCount, StreamCount