diff --git a/analytics/lib/counts.py b/analytics/lib/counts.py index b1a6e9f68a..3d64adf5e6 100644 --- a/analytics/lib/counts.py +++ b/analytics/lib/counts.py @@ -206,7 +206,7 @@ def do_aggregate_to_summary_table( # Aggregate into RealmCount output_table = stat.data_collector.output_table if realm is not None: - realm_clause = SQL("AND zerver_realm.id = {}").format(Literal(realm.id)) + realm_clause: Composable = SQL("AND zerver_realm.id = {}").format(Literal(realm.id)) else: realm_clause = SQL("") @@ -357,7 +357,7 @@ def do_pull_by_sql_query( ) -> int: if group_by is None: subgroup: Composable = SQL("NULL") - group_by_clause = SQL("") + group_by_clause: Composable = SQL("") else: subgroup = Identifier(group_by[0]._meta.db_table, group_by[1]) group_by_clause = SQL(", {}").format(subgroup) @@ -443,7 +443,7 @@ def do_pull_minutes_active( def count_message_by_user_query(realm: Optional[Realm]) -> QueryFn: if realm is None: - realm_clause = SQL("") + realm_clause: Composable = SQL("") else: realm_clause = SQL("zerver_userprofile.realm_id = {} AND").format(Literal(realm.id)) return lambda kwargs: SQL( @@ -470,7 +470,7 @@ def count_message_by_user_query(realm: Optional[Realm]) -> QueryFn: # Note: ignores the group_by / group_by_clause. def count_message_type_by_user_query(realm: Optional[Realm]) -> QueryFn: if realm is None: - realm_clause = SQL("") + realm_clause: Composable = SQL("") else: realm_clause = SQL("zerver_userprofile.realm_id = {} AND").format(Literal(realm.id)) return lambda kwargs: SQL( @@ -519,7 +519,7 @@ def count_message_type_by_user_query(realm: Optional[Realm]) -> QueryFn: # table, consider writing a new query for efficiency. def count_message_by_stream_query(realm: Optional[Realm]) -> QueryFn: if realm is None: - realm_clause = SQL("") + realm_clause: Composable = SQL("") else: realm_clause = SQL("zerver_stream.realm_id = {} AND").format(Literal(realm.id)) return lambda kwargs: SQL( @@ -553,7 +553,7 @@ def count_message_by_stream_query(realm: Optional[Realm]) -> QueryFn: # currently the only stat that uses this. def count_user_by_realm_query(realm: Optional[Realm]) -> QueryFn: if realm is None: - realm_clause = SQL("") + realm_clause: Composable = SQL("") else: realm_clause = SQL("zerver_userprofile.realm_id = {} AND").format(Literal(realm.id)) return lambda kwargs: SQL( @@ -583,7 +583,7 @@ def count_user_by_realm_query(realm: Optional[Realm]) -> QueryFn: # In particular, it's important to ensure that migrations don't cause that to happen. def check_realmauditlog_by_user_query(realm: Optional[Realm]) -> QueryFn: if realm is None: - realm_clause = SQL("") + realm_clause: Composable = SQL("") else: realm_clause = SQL("realm_id = {} AND").format(Literal(realm.id)) return lambda kwargs: SQL( @@ -623,7 +623,7 @@ def check_realmauditlog_by_user_query(realm: Optional[Realm]) -> QueryFn: def check_useractivityinterval_by_user_query(realm: Optional[Realm]) -> QueryFn: if realm is None: - realm_clause = SQL("") + realm_clause: Composable = SQL("") else: realm_clause = SQL("zerver_userprofile.realm_id = {} AND").format(Literal(realm.id)) return lambda kwargs: SQL( @@ -647,7 +647,7 @@ def check_useractivityinterval_by_user_query(realm: Optional[Realm]) -> QueryFn: def count_realm_active_humans_query(realm: Optional[Realm]) -> QueryFn: if realm is None: - realm_clause = SQL("") + realm_clause: Composable = SQL("") else: realm_clause = SQL("realm_id = {} AND").format(Literal(realm.id)) return lambda kwargs: SQL( diff --git a/analytics/views/installation_activity.py b/analytics/views/installation_activity.py index 5bbe3ab1a7..aefba2623c 100644 --- a/analytics/views/installation_activity.py +++ b/analytics/views/installation_activity.py @@ -410,7 +410,7 @@ def ad_hoc_queries() -> List[Dict[str, str]]: for mobile_type in ["Android", "ZulipiOS"]: title = f"{mobile_type} usage" - query = SQL( + query: Composable = SQL( """ select realm.string_id,