Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Add 'Ignored' flags to Moderator Activity report #22041

Merged
merged 2 commits into from Aug 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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