discourse/app/jobs/regular/mass_award_badge.rb
Osama Sayegh 31aa701518
FEATURE: Add option to grant badge multiple times to users using Bulk Award (#13571)
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.
2021-07-15 05:53:26 +03:00

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