mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 23:06:57 +08:00
31aa701518
Currently when bulk-awarding a badge that can be granted multiple times, users in the CSV file are granted the badge once no matter how many times they're listed in the file and only if they don't have the badge already. This PR adds a new option to the Badge Bulk Award feature so that it's possible to grant users a badge even if they already have the badge and as many times as they appear in the CSV file.
15 lines
347 B
Ruby
15 lines
347 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Jobs
|
|
class MassAwardBadge < ::Jobs::Base
|
|
def execute(args)
|
|
user = User.find_by(id: args[:user])
|
|
return if user.blank?
|
|
badge = Badge.find_by(enabled: true, id: args[:badge])
|
|
return if badge.blank?
|
|
|
|
BadgeGranter.mass_grant(badge, user, count: args[:count])
|
|
end
|
|
end
|
|
end
|