mirror of
https://github.com/discourse/discourse.git
synced 2026-08-14 06:55:03 -05:00
FIX: Recalculate scores only when approving or transitioning to pending. (#13009)
Recalculating a ReviewableFlaggedPost's score after rejecting or ignoring it sets the score as 0, which means that we can't find them after reviewing. They don't surpass the minimum priority threshold and are hidden. Additionally, we only want to use agreed flags when calculating the different priority thresholds.
This commit is contained in:
@@ -175,7 +175,13 @@ class Reviewable < ActiveRecord::Base
|
||||
reviewable.save!
|
||||
else
|
||||
reviewable = find_by(target: target)
|
||||
reviewable.log_history(:transitioned, created_by) if old_status != statuses[:pending]
|
||||
|
||||
if old_status != statuses[:pending]
|
||||
# If we're transitioning back from reviewed to pending, we should recalculate
|
||||
# the score to prevent posts from being hidden.
|
||||
reviewable.recalculate_score
|
||||
reviewable.log_history(:transitioned, created_by)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -584,8 +590,6 @@ class Reviewable < ActiveRecord::Base
|
||||
SQL
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def recalculate_score
|
||||
# pending/agreed scores count
|
||||
sql = <<~SQL
|
||||
@@ -633,6 +637,8 @@ protected
|
||||
self.score
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def increment_version!(version = nil)
|
||||
version_result = nil
|
||||
|
||||
|
||||
Reference in New Issue
Block a user