about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2022-10-14 01:44:23 +0200
committerGitHub <noreply@github.com>2022-10-14 01:44:23 +0200
commitf01310dadbca94c74aa44e0a4725d49c5ac15434 (patch)
treef23be5d4e23f9971646f0926e01381dea791e457 /app
parent8a9d774a84b59db7d4d973be4392e50ddebf2484 (diff)
Fix trending statuses returning more than one post by the same author (#19349)
Diffstat (limited to 'app')
-rw-r--r--app/models/status_trend.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/app/models/status_trend.rb b/app/models/status_trend.rb
index 33fd6b004..b0f1b6942 100644
--- a/app/models/status_trend.rb
+++ b/app/models/status_trend.rb
@@ -17,5 +17,5 @@ class StatusTrend < ApplicationRecord
   belongs_to :status
   belongs_to :account
 
-  scope :allowed, -> { where(allowed: true) }
+  scope :allowed, -> { joins('INNER JOIN (SELECT account_id, MAX(score) AS max_score FROM status_trends GROUP BY account_id) AS grouped_status_trends ON status_trends.account_id = grouped_status_trends.account_id AND status_trends.score = grouped_status_trends.max_score').where(allowed: true) }
 end