discourse/app/jobs/regular/mass_award_badge.rb
Roman Rizzi d69c5eebcf
Feature: Mass award badge (#8694)
* UI: Mass grant a badge from the admin ui

* Send the uploaded CSV and badge ID to the backend

* Read the CSV and grant badge in batches

* UX: Communicate the result to the user

* Don't award if badge is disabled

* Create a 'send_notification' method to remove duplicated code, slightly shrink badge image. Replace router transition with href.

* Dynamically discover current route
2020-01-13 11:20:26 -03:00

15 lines
341 B
Ruby

# frozen_string_literal: true
module Jobs
class MassAwardBadge < ::Jobs::Base
def execute(args)
badge = Badge.find_by(id: args[:badge_id])
users = User.select(:id, :username, :locale).with_email(args[:user_emails])
return if users.empty? || badge.nil?
BadgeGranter.mass_grant(badge, users)
end
end
end