Don't give notifications to admins for trust level notifications
This commit is contained in:
parent
00ffc49105
commit
7341b0d03c
|
@ -1,3 +1,5 @@
|
||||||
|
require_dependency 'slug'
|
||||||
|
|
||||||
class Badge < ActiveRecord::Base
|
class Badge < ActiveRecord::Base
|
||||||
# NOTE: These badge ids are not in order! They are grouped logically.
|
# NOTE: These badge ids are not in order! They are grouped logically.
|
||||||
# When picking an id, *search* for it.
|
# When picking an id, *search* for it.
|
||||||
|
@ -119,6 +121,10 @@ class Badge < ActiveRecord::Base
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def awarded_for_trust_level?
|
||||||
|
id <= 4
|
||||||
|
end
|
||||||
|
|
||||||
def reset_grant_count!
|
def reset_grant_count!
|
||||||
self.grant_count = UserBadge.where(badge_id: id).count
|
self.grant_count = UserBadge.where(badge_id: id).count
|
||||||
save!
|
save!
|
||||||
|
@ -208,6 +214,7 @@ SQL
|
||||||
def i18n_name
|
def i18n_name
|
||||||
self.name.downcase.tr(' ', '_')
|
self.name.downcase.tr(' ', '_')
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
|
|
|
@ -274,7 +274,7 @@ class BadgeGranter
|
||||||
/*where*/
|
/*where*/
|
||||||
RETURNING id, user_id, granted_at
|
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
|
JOIN users u on u.id = w.user_id
|
||||||
"
|
"
|
||||||
|
|
||||||
|
@ -315,6 +315,8 @@ class BadgeGranter
|
||||||
# Make this variable in this scope
|
# Make this variable in this scope
|
||||||
notification = nil
|
notification = nil
|
||||||
|
|
||||||
|
next if (row.admin && badge.awarded_for_trust_level?)
|
||||||
|
|
||||||
I18n.with_locale(notification_locale) do
|
I18n.with_locale(notification_locale) do
|
||||||
notification = Notification.create!(
|
notification = Notification.create!(
|
||||||
user_id: row.user_id,
|
user_id: row.user_id,
|
||||||
|
|
Loading…
Reference in New Issue