mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 15:32:26 +08:00
FIX: ensures flag-ratio report shows users with disagreed > agreed (#7977)
Without causing a division by zero error
This commit is contained in:
parent
37e7998a82
commit
a475c384d8
|
@ -53,7 +53,10 @@ Report.add_report("user_flagging_ratio") do |report|
|
||||||
#{disagreed} AS disagreed_flags,
|
#{disagreed} AS disagreed_flags,
|
||||||
#{agreed} AS agreed_flags,
|
#{agreed} AS agreed_flags,
|
||||||
#{ignored} AS ignored_flags,
|
#{ignored} AS ignored_flags,
|
||||||
ROUND((1-(#{agreed} / #{disagreed})) * (#{disagreed} - #{agreed})) AS score
|
(
|
||||||
|
CASE #{disagreed} WHEN 0 THEN #{agreed} * #{agreed}
|
||||||
|
ELSE ROUND((1-(#{agreed} / #{disagreed})) * (#{disagreed} - #{agreed})) END
|
||||||
|
) AS score
|
||||||
FROM users AS u
|
FROM users AS u
|
||||||
INNER JOIN reviewable_scores AS rs ON rs.user_id = u.id
|
INNER JOIN reviewable_scores AS rs ON rs.user_id = u.id
|
||||||
WHERE u.id > 0
|
WHERE u.id > 0
|
||||||
|
@ -63,7 +66,6 @@ Report.add_report("user_flagging_ratio") do |report|
|
||||||
u.username,
|
u.username,
|
||||||
u.uploaded_avatar_id,
|
u.uploaded_avatar_id,
|
||||||
u.silenced_till
|
u.silenced_till
|
||||||
HAVING #{disagreed} > #{agreed}
|
|
||||||
ORDER BY score DESC
|
ORDER BY score DESC
|
||||||
LIMIT 100
|
LIMIT 100
|
||||||
SQL
|
SQL
|
||||||
|
|
Loading…
Reference in New Issue
Block a user