FIX: ensures flag-ratio report shows users with disagreed > agreed (#7977)

Without causing a division by zero error
This commit is contained in:
Joffrey JAFFEUX 2019-08-06 15:02:45 +02:00 committed by GitHub
parent 37e7998a82
commit a475c384d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -53,7 +53,10 @@ Report.add_report("user_flagging_ratio") do |report|
#{disagreed} AS disagreed_flags,
#{agreed} AS agreed_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
INNER JOIN reviewable_scores AS rs ON rs.user_id = u.id
WHERE u.id > 0
@ -63,7 +66,6 @@ Report.add_report("user_flagging_ratio") do |report|
u.username,
u.uploaded_avatar_id,
u.silenced_till
HAVING #{disagreed} > #{agreed}
ORDER BY score DESC
LIMIT 100
SQL