From d5e369d6cffab4f4f59a05f3053baf94f9184fa6 Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Mon, 23 Oct 2017 12:30:28 +0800 Subject: [PATCH] Fix weird Rubocop error. --- app/jobs/scheduled/pending_users_reminder.rb | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/app/jobs/scheduled/pending_users_reminder.rb b/app/jobs/scheduled/pending_users_reminder.rb index 36448e37c26..af0a1b17ca1 100644 --- a/app/jobs/scheduled/pending_users_reminder.rb +++ b/app/jobs/scheduled/pending_users_reminder.rb @@ -19,12 +19,16 @@ module Jobs count = query.count if count > 0 - target_usernames = Group[:moderators].users.map do |u| - u.id > 0 && u.notifications.joins(:topic) - .where("notifications.id > ?", u.seen_notification_id) + target_usernames = Group[:moderators].users.map do |user| + next if user.id < 0 + + count = user.notifications.joins(:topic) + .where("notifications.id > ?", user.seen_notification_id) .where("notifications.read = false") - .where("topics.subtype = '#{TopicSubtype.pending_users_reminder}'") - .count == 0 ? u.username : nil + .where("topics.subtype = ?", TopicSubtype.pending_users_reminder) + .count + + count == 0 ? user.username : nil end.compact unless target_usernames.empty?