From 7d501058d7e0aec2d29775e7d781afa393478a5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Tue, 13 Feb 2018 17:32:38 +0100 Subject: [PATCH] FIX: don't grant new user of the month badge to suspended users or based on deleted topics/posts --- app/jobs/scheduled/grant_new_user_of_the_month_badges.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/jobs/scheduled/grant_new_user_of_the_month_badges.rb b/app/jobs/scheduled/grant_new_user_of_the_month_badges.rb index 86d3a3a1d93..5a2803b7206 100644 --- a/app/jobs/scheduled/grant_new_user_of_the_month_badges.rb +++ b/app/jobs/scheduled/grant_new_user_of_the_month_badges.rb @@ -64,12 +64,16 @@ module Jobs LEFT OUTER JOIN topics AS t ON t.id = p.topic_id WHERE u.active AND u.id > 0 + AND u.id NOT IN (#{current_owners.join(',')}) AND NOT u.staged AND NOT u.admin AND NOT u.moderator - AND t.archetype <> '#{Archetype.private_message}' + AND u.suspended_at IS NULL + AND u.suspended_till IS NULL AND u.created_at >= CURRENT_TIMESTAMP - '1 month'::INTERVAL - AND u.id NOT IN (#{current_owners.join(',')}) + AND t.archetype <> '#{Archetype.private_message}' + AND t.deleted_at IS NULL + AND p.deleted_at IS NULL GROUP BY u.id HAVING COUNT(DISTINCT p.id) > 1 AND COUNT(DISTINCT p.topic_id) > 1