analytics: Remove HuddleCount for now.

Planned changes to the underlying analytics model will require potentially
complicated changes to huddle queries.
This commit is contained in:
umkay 2016-10-11 19:05:17 -07:00 committed by Tim Abbott
parent 7787b780bc
commit 721529b782
5 changed files with 35 additions and 45 deletions

View File

@ -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'),

View File

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

View File

@ -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',
),
]

View File

@ -120,24 +120,3 @@ class StreamCount(BaseCount):
def __unicode__(self):
# type: () -> text_type
return u"<StreamCount: %s %s %s %s>" % (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"<HuddleCount: %s %s %s %s>" % (self.huddle, self.property, self.value, self.id)

View File

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