mirror of
https://github.com/System-End/hackatime.git
synced 2026-04-19 21:05:15 +00:00
26 lines
627 B
Ruby
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
|