Add BadgeRewarder class and rake for auto badging (#367)
This commit is contained in:
parent
6d3c2e050f
commit
0d82c50a3d
2 changed files with 16 additions and 0 deletions
9
app/labor/badge_rewarder.rb
Normal file
9
app/labor/badge_rewarder.rb
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
class BadgeRewarder
|
||||
def award_yearly_club_badges
|
||||
message = "Happy DEV birthday!"
|
||||
User.where("created_at < ? AND created_at > ?",1.year.ago, 367.days.ago).each do |user|
|
||||
BadgeAchievement.create(user_id: user.id, badge_id: 2, rewarding_context_message: message)
|
||||
# ID 2 is the proper ID in prod. We should change in future to ENV var.
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -63,5 +63,12 @@ task :github_repo_fetch_all => :environment do
|
|||
end
|
||||
|
||||
task :send_email_digest => :environment do
|
||||
return if Time.now.wday < 3
|
||||
EmailDigest.send_periodic_digest_email
|
||||
end
|
||||
|
||||
task :award_badges => :environment do
|
||||
BadgeRewarder.new.award_yearly_club_badges
|
||||
end
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue