analytics: Change messages_sent:is_bot to hourly frequency.

In preparation for replacing messages_sent.
This commit is contained in:
Rishi Gupta 2017-01-16 13:39:03 -08:00 committed by Tim Abbott
parent 68fcb4152f
commit b593ac9d7c
4 changed files with 9 additions and 9 deletions

View File

@ -340,9 +340,9 @@ COUNT_STATS = {
(UserProfile, 'is_bot'), CountStat.DAY, True),
'messages_sent:hour': CountStat(
'messages_sent:hour', zerver_count_message_by_user, {}, None, CountStat.HOUR, False),
'messages_sent:is_bot:day': CountStat(
'messages_sent:is_bot:day', zerver_count_message_by_user, {},
(UserProfile, 'is_bot'), CountStat.DAY, False),
'messages_sent:is_bot:hour': CountStat(
'messages_sent:is_bot:hour', zerver_count_message_by_user, {},
(UserProfile, 'is_bot'), CountStat.HOUR, False),
'messages_sent:message_type:day': CountStat(
'messages_sent:message_type:day', zerver_count_message_type_by_user, {},
None, CountStat.DAY, False),

View File

@ -82,7 +82,7 @@ class Command(BaseCommand):
realm_data = {None: self.generate_fixture_data(stat, 50, 30, 5, .6, 3)}
insert_fixture_data(stat, realm_data, RealmCount)
stat = COUNT_STATS['messages_sent:is_bot:day']
stat = COUNT_STATS['messages_sent:is_bot:hour']
user_data = {'false': self.generate_fixture_data(stat, 2, 1, 1.5, .6, 8)}
insert_fixture_data(stat, user_data, UserCount)
realm_data = {'false': self.generate_fixture_data(stat, 35, 15, 6, .6, 4),

View File

@ -274,7 +274,7 @@ class TestCountStats(AnalyticsTestCase):
def test_messages_sent_by_is_bot(self):
# type: () -> None
stat = COUNT_STATS['messages_sent:is_bot:day']
stat = COUNT_STATS['messages_sent:is_bot:hour']
self.current_property = stat.property
bot = self.create_user(is_bot=True)
@ -295,10 +295,10 @@ class TestCountStats(AnalyticsTestCase):
self.assertTableState(UserCount, ['value', 'subgroup', 'user'],
[[1, 'false', human1], [1, 'false', human2], [3, 'true', bot],
[1, 'false', self.hourly_user], [1, 'false', self.daily_user]])
[1, 'false', self.hourly_user]])
self.assertTableState(RealmCount, ['value', 'subgroup', 'realm'],
[[2, 'false'], [3, 'true'], [2, 'false', self.second_realm]])
self.assertTableState(InstallationCount, ['value', 'subgroup'], [[4, 'false'], [3, 'true']])
[[2, 'false'], [3, 'true'], [1, 'false', self.second_realm]])
self.assertTableState(InstallationCount, ['value', 'subgroup'], [[3, 'false'], [3, 'true']])
self.assertTableState(StreamCount, [], [])
def test_messages_sent_by_message_type(self):

View File

@ -113,7 +113,7 @@ def get_number_of_humans(realm, start, end, min_length=None):
def get_messages_sent_by_humans_and_bots(realm, start, end, min_length=None):
# type: (Realm, datetime, datetime, Optional[int]) -> Dict[str, Any]
stat = COUNT_STATS['messages_sent:is_bot:day']
stat = COUNT_STATS['messages_sent:is_bot:hour']
end_times, values = get_time_series_by_subgroup(
stat, RealmCount, realm.id, ['false', 'true'], start, end, min_length)
return {'end_times': end_times, 'humans': values['false'], 'bots': values['true'],