This repository was archived by the owner on Apr 26, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
synapse/storage/databases/main Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -490,6 +490,10 @@ def _get_thread_summaries_txn(
490
490
if parent_event_id not in latest_event_ids :
491
491
latest_event_ids [parent_event_id ] = child_event_id
492
492
493
+ # If no threads were found, bail.
494
+ if not latest_event_ids :
495
+ return {}, latest_event_ids
496
+
493
497
# Fetch the number of threaded replies.
494
498
sql = """
495
499
SELECT parent.event_id, COUNT(child.event_id) FROM events AS child
@@ -502,7 +506,14 @@ def _get_thread_summaries_txn(
502
506
AND relation_type = ?
503
507
GROUP BY parent.event_id
504
508
"""
505
- # TODO Re-generate args since we know some events don't have threads now.
509
+
510
+ # Regenerate the arguments since only threads found above could
511
+ # possibly have any replies.
512
+ clause , args = make_in_list_sql_clause (
513
+ txn .database_engine , "relates_to_id" , latest_event_ids .keys ()
514
+ )
515
+ args .append (RelationTypes .THREAD )
516
+
506
517
txn .execute (sql % (clause ,), args )
507
518
counts = dict (cast (List [Tuple [str , int ]], txn .fetchall ()))
508
519
You can’t perform that action at this time.
0 commit comments