diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-18 22:00:14 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-18 22:00:14 +0300 |
commit | 05f0ebba3a2c8ddf39e436f412dc2ab5bf1353b2 (patch) | |
tree | 11d0f2a6ec31c7793c184106cedc2ded3d9a2cc5 /app/workers/gitlab/github_gists_import/finish_import_worker.rb | |
parent | ec73467c23693d0db63a797d10194da9e72a74af (diff) |
Add latest changes from gitlab-org/gitlab@15-8-stable-eev15.8.0-rc42
Diffstat (limited to 'app/workers/gitlab/github_gists_import/finish_import_worker.rb')
-rw-r--r-- | app/workers/gitlab/github_gists_import/finish_import_worker.rb | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/app/workers/gitlab/github_gists_import/finish_import_worker.rb b/app/workers/gitlab/github_gists_import/finish_import_worker.rb index 1989b6314ea..284e5833f0c 100644 --- a/app/workers/gitlab/github_gists_import/finish_import_worker.rb +++ b/app/workers/gitlab/github_gists_import/finish_import_worker.rb @@ -18,14 +18,15 @@ module Gitlab INTERVAL = 30.seconds.to_i BLOCKING_WAIT_TIME = 5 + GISTS_ERRORS_BY_ID = 'gitlab:github-gists-import:%{user_id}:errors' def perform(user_id, waiter_key, remaining) waiter = wait_for_jobs(waiter_key, remaining) if waiter.nil? Gitlab::GithubGistsImport::Status.new(user_id).finish! - Gitlab::GithubImport::Logger.info(user_id: user_id, message: 'GitHub Gists import finished') + send_email_if_errors(user_id) else self.class.perform_in(INTERVAL, user_id, waiter.key, waiter.jobs_remaining) end @@ -41,6 +42,17 @@ module Gitlab waiter end + + def send_email_if_errors(user_id) + key = format(GISTS_ERRORS_BY_ID, user_id: user_id) + errors = ::Gitlab::Cache::Import::Caching.values_from_hash(key) + + return if errors.blank? + + Notify.github_gists_import_errors_email(user_id, errors).deliver_now + ensure + ::Gitlab::Cache::Import::Caching.expire(key, ::Gitlab::Cache::Import::Caching::SHORTER_TIMEOUT) + end end end end |