Skip to content

Commit

Permalink
Deduplicate unique accounts and limit account array in descendants CTE
Browse files Browse the repository at this point in the history
Limit unique accounts to check blocks from to 30 unique accounts (any new
participant will have its blocks ignored for the purpose of displaying the
posts). This is extremely unlikely to be reached in a legitimate situation,
but would limit wasteful computation in specially-crafted threads with many
participants.
  • Loading branch information
ClearlyClaire committed May 27, 2024
1 parent c3f5de4 commit ceeed33
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/models/concerns/status/threading_concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,11 @@ def descendant_ids(limit, depth)
UNION ALL
SELECT
statuses.id, path || statuses.id, authors || statuses.account_id
statuses.id, path || statuses.id, (CASE
WHEN array_length(authors, 1) >= 30 THEN authors
WHEN statuses.account_id = ANY(authors) THEN authors
ELSE authors || statuses.account_id
END)
FROM
search_tree
JOIN
Expand Down

0 comments on commit ceeed33

Please sign in to comment.