diff --git a/app/jobs/sailors_log_poll_for_changes_job.rb b/app/jobs/sailors_log_poll_for_changes_job.rb index 97658a8..560c382 100644 --- a/app/jobs/sailors_log_poll_for_changes_job.rb +++ b/app/jobs/sailors_log_poll_for_changes_job.rb @@ -30,6 +30,9 @@ class SailorsLogPollForChangesJob < ApplicationJob private def update_sailors_log(sailors_log) + # Skip if there's an active migration job for this user + return [] if sailors_log.user.in_progress_migration_jobs? + project_updates = [] project_durations = Heartbeat.where(user_id: sailors_log.user.id) .group(:project).duration_seconds diff --git a/app/models/user.rb b/app/models/user.rb index 603bf1e..db6f3c6 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -67,6 +67,13 @@ class User < ApplicationRecord ).order(created_at: :desc).limit(10).all end + def in_progress_migration_jobs? + GoodJob::Job.where(job_class: "MigrateUserFromHackatimeJob") + .where("serialized_params->>'arguments' = ?", [ id ].to_json) + .where(finished_at: nil) + .exists? + end + def set_neighborhood_channel return unless slack_uid.present?