From 51c1a6dfc9320c8ba69ff7af0db70280e586c027 Mon Sep 17 00:00:00 2001 From: rht Date: Sat, 4 Nov 2017 12:38:25 +0100 Subject: [PATCH] analytics: Text-wrap long lines exceeding 110. License: Apache-2.0 Signed-off-by: rht --- analytics/lib/counts.py | 13 +++++++++---- analytics/management/commands/stream_stats.py | 3 ++- .../management/commands/update_analytics_counts.py | 3 ++- analytics/models.py | 3 ++- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/analytics/lib/counts.py b/analytics/lib/counts.py index 518430e353..0f406a06d9 100644 --- a/analytics/lib/counts.py +++ b/analytics/lib/counts.py @@ -177,7 +177,8 @@ def do_aggregate_to_summary_table(stat, end_time): start = time.time() cursor.execute(realmcount_query, {'end_time': end_time}) end = time.time() - logger.info("%s RealmCount aggregation (%dms/%sr)" % (stat.property, (end-start)*1000, cursor.rowcount)) + logger.info("%s RealmCount aggregation (%dms/%sr)" % ( + stat.property, (end - start) * 1000, cursor.rowcount)) # Aggregate into InstallationCount installationcount_query = """ @@ -194,7 +195,8 @@ def do_aggregate_to_summary_table(stat, end_time): start = time.time() cursor.execute(installationcount_query, {'end_time': end_time}) end = time.time() - logger.info("%s InstallationCount aggregation (%dms/%sr)" % (stat.property, (end-start)*1000, cursor.rowcount)) + logger.info("%s InstallationCount aggregation (%dms/%sr)" % ( + stat.property, (end - start) * 1000, cursor.rowcount)) cursor.close() ## Utility functions called from outside counts.py ## @@ -294,7 +296,8 @@ count_message_by_user_query = """ INSERT INTO analytics_usercount (user_id, realm_id, value, property, subgroup, end_time) SELECT - zerver_userprofile.id, zerver_userprofile.realm_id, count(*), '%(property)s', %(subgroup)s, %%(time_end)s + zerver_userprofile.id, zerver_userprofile.realm_id, count(*), + '%(property)s', %(subgroup)s, %%(time_end)s FROM zerver_userprofile JOIN zerver_message ON @@ -336,7 +339,9 @@ count_message_type_by_user_query = """ LEFT JOIN zerver_stream ON zerver_recipient.type_id = zerver_stream.id - GROUP BY zerver_userprofile.realm_id, zerver_userprofile.id, zerver_recipient.type, zerver_stream.invite_only + GROUP BY + zerver_userprofile.realm_id, zerver_userprofile.id, + zerver_recipient.type, zerver_stream.invite_only ) AS subquery GROUP BY realm_id, id, message_type """ diff --git a/analytics/management/commands/stream_stats.py b/analytics/management/commands/stream_stats.py index 371d238f1b..c6e4b46603 100644 --- a/analytics/management/commands/stream_stats.py +++ b/analytics/management/commands/stream_stats.py @@ -36,7 +36,8 @@ class Command(BaseCommand): continue print("%25s" % (stream.name,), end=' ') recipient = Recipient.objects.filter(type=Recipient.STREAM, type_id=stream.id) - print("%10d" % (len(Subscription.objects.filter(recipient=recipient, active=True)),), end=' ') + print("%10d" % (len(Subscription.objects.filter(recipient=recipient, + active=True)),), end=' ') num_messages = len(Message.objects.filter(recipient=recipient)) print("%12d" % (num_messages,)) print("%d invite-only streams" % (invite_only_count,)) diff --git a/analytics/management/commands/update_analytics_counts.py b/analytics/management/commands/update_analytics_counts.py index b479886194..3cbf004899 100644 --- a/analytics/management/commands/update_analytics_counts.py +++ b/analytics/management/commands/update_analytics_counts.py @@ -25,7 +25,8 @@ class Command(BaseCommand): # type: (ArgumentParser) -> None parser.add_argument('--time', '-t', type=str, - help='Update stat tables from current state to --time. Defaults to the current time.', + help='Update stat tables from current state to' + '--time. Defaults to the current time.', default=timezone_now().isoformat()) parser.add_argument('--utc', action='store_true', diff --git a/analytics/models.py b/analytics/models.py index e3bbd120c7..00f9fc96b6 100644 --- a/analytics/models.py +++ b/analytics/models.py @@ -105,4 +105,5 @@ class StreamCount(BaseCount): def __str__(self): # type: () -> Text - return "" % (self.stream, self.property, self.subgroup, self.value, self.id) + return "" % ( + self.stream, self.property, self.subgroup, self.value, self.id)