[deploy] Refactor: Move beloved comment Badge to Sidekiq Cron (#9861)

This commit is contained in:
Molly Struve 2020-08-19 08:12:45 -05:00 committed by GitHub
parent d0c64206a3
commit 960c51fbc0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 2 deletions

View file

@ -28,7 +28,7 @@ module BadgeRewarder
def self.award_beloved_comment_badges(comment_count = 24)
badge_id = Badge.find_by!(slug: "beloved-comment").id
Comment.where("public_reactions_count > ?", comment_count).find_each do |comment|
Comment.includes(:user).where("public_reactions_count > ?", comment_count).find_each do |comment|
message = "You're famous! [This is the comment](#{URL.comment(comment)}) for which you are being recognized. 😄"
achievement = BadgeAchievement.create(
user_id: comment.user_id,

View file

@ -17,3 +17,10 @@ award_yearly_club_badges:
- ""
- award_yearly_club_badges
- ""
award_beloved_comment_badges:
cron: "5 0 * * *" # daily at 12:05 am UTC
class: "BadgeAchievements::BadgeAwardWorker"
args:
- ""
- award_beloved_comment_badges
- ""

View file

@ -1,5 +1,4 @@
task award_badges: :environment do
BadgeRewarder.award_beloved_comment_badges
BadgeRewarder.award_streak_badge(4)
BadgeRewarder.award_streak_badge(8)
BadgeRewarder.award_streak_badge(16)