Don't give notifications to admins for trust level notifications

This commit is contained in:
Robin Ward 2017-01-10 12:18:48 -05:00
parent 00ffc49105
commit 7341b0d03c
2 changed files with 10 additions and 1 deletions

View File

@ -1,3 +1,5 @@
require_dependency 'slug'
class Badge < ActiveRecord::Base
# NOTE: These badge ids are not in order! They are grouped logically.
# When picking an id, *search* for it.
@ -119,6 +121,10 @@ class Badge < ActiveRecord::Base
}
end
def awarded_for_trust_level?
id <= 4
end
def reset_grant_count!
self.grant_count = UserBadge.where(badge_id: id).count
save!
@ -208,6 +214,7 @@ SQL
def i18n_name
self.name.downcase.tr(' ', '_')
end
end
# == Schema Information

View File

@ -274,7 +274,7 @@ class BadgeGranter
/*where*/
RETURNING id, user_id, granted_at
)
select w.*, username, locale FROM w
select w.*, username, locale, u.admin FROM w
JOIN users u on u.id = w.user_id
"
@ -315,6 +315,8 @@ class BadgeGranter
# Make this variable in this scope
notification = nil
next if (row.admin && badge.awarded_for_trust_level?)
I18n.with_locale(notification_locale) do
notification = Notification.create!(
user_id: row.user_id,