hackatime/app/jobs/slack_username_update_job.rb
Mahad Kalam 28fa174861
Add Sentry monitoring for previously unreported errors (#1066)
* Add Sentry monitoring for previously unreported errors

* Fix

* Fixes

* whoops!
2026-03-13 11:06:12 +00:00

26 lines
627 B
Ruby

class SlackUsernameUpdateJob < ApplicationJob
queue_as :latency_5m
include GoodJob::ActiveJobExtensions::Concurrency
# Limits concurrency to 1 job per date
good_job_control_concurrency_with(
total: 1,
drop: true
)
def perform
User
.where.not(slack_uid: nil)
.order(Arel.sql("slack_synced_at IS NOT NULL, slack_synced_at ASC"))
.limit(100)
.each do |user|
begin
user.update_from_slack
user.save!
rescue => e
report_error(e, message: "Failed to update Slack username and avatar for user #{user.id}")
end
end
end
end