Skip to content

Commit

Permalink
FIX: Add 'Ignored' flags to Moderator Activity report (#22041)
Browse files Browse the repository at this point in the history
* FIX Add 'Ignored' flags to Moderator Activity report

The Moderator Activity query didn’t include the number of deferred flags in the Flags Reviewed totals. As this number is designed to reflect how many flags a moderator has seen, reviewed, and made a judgement on, the Ignored ones should also be included.

* Apply suggestions from code review

---------

Co-authored-by: Jarek Radosz <jradosz@gmail.com>
  • Loading branch information
JimmyJammyDodger and CvX committed Aug 2, 2023
1 parent 407ff39 commit e680437
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions app/models/concerns/reports/moderators_activity.rb
Expand Up @@ -73,7 +73,8 @@ def report_moderators_activity(report)
flag_count AS (
WITH period_actions AS (
SELECT agreed_by_id,
disagreed_by_id
disagreed_by_id,
deferred_by_id
FROM post_actions
WHERE post_action_type_id IN (#{PostActionType.flag_types_without_custom.values.join(",")})
AND created_at >= '#{report.start_date}'
Expand All @@ -94,13 +95,23 @@ def report_moderators_activity(report)
JOIN period_actions pa
ON pa.disagreed_by_id = m.user_id
GROUP BY disagreed_by_id
),
deferred_flags AS (
SELECT pa.deferred_by_id AS user_id,
COUNT(*) AS flag_count
FROM mods m
JOIN period_actions pa
ON pa.deferred_by_id = m.user_id
GROUP BY deferred_by_id
)
SELECT
COALESCE(af.user_id, df.user_id) AS user_id,
COALESCE(af.flag_count, 0) + COALESCE(df.flag_count, 0) AS flag_count
COALESCE(af.user_id, df.user_id, def.user_id) AS user_id,
COALESCE(af.flag_count, 0) + COALESCE(df.flag_count, 0) + COALESCE(def.flag_count, 0) AS flag_count
FROM agreed_flags af
FULL OUTER JOIN disagreed_flags df
ON df.user_id = af.user_id
FULL OUTER JOIN deferred_flags def
ON def.user_id = af.user_id
),
revision_count AS (
SELECT pr.user_id,
Expand Down

0 comments on commit e680437

Please sign in to comment.