Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
488afee0
Commit
488afee0
authored
Apr 03, 2020
by
Alexandru Croitor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract sidekiq job tracking to a separate concer
Reuse sidekiq job tracking as a concern on import state models
parent
c35f6d5e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
24 deletions
+25
-24
app/models/concerns/import_state/sidekiq_job_tracker.rb
app/models/concerns/import_state/sidekiq_job_tracker.rb
+23
-0
app/models/jira_import_state.rb
app/models/jira_import_state.rb
+1
-10
app/models/project_import_state.rb
app/models/project_import_state.rb
+1
-14
No files found.
app/models/concerns/import_state/sidekiq_job_tracker.rb
0 → 100644
View file @
488afee0
# frozen_string_literal: true
module
ImportState
module
SidekiqJobTracker
extend
ActiveSupport
::
Concern
included
do
# Refreshes the expiration time of the associated import job ID.
#
# This method can be used by asynchronous importers to refresh the status,
# preventing the StuckImportJobsWorker from marking the import as failed.
def
refresh_jid_expiration
return
unless
jid
Gitlab
::
SidekiqStatus
.
set
(
jid
,
StuckImportJobsWorker
::
IMPORT_JOBS_EXPIRATION
)
end
def
self
.
jid_by
(
project_id
:,
status
:)
select
(
:jid
).
with_status
(
status
).
find_by
(
project_id:
project_id
)
end
end
end
end
app/models/jira_import_state.rb
View file @
488afee0
...
...
@@ -2,6 +2,7 @@
class
JiraImportState
<
ApplicationRecord
include
AfterCommitQueue
include
ImportState
::
SidekiqJobTracker
self
.
table_name
=
'jira_imports'
...
...
@@ -66,14 +67,4 @@ class JiraImportState < ApplicationRecord
def
in_progress?
scheduled?
||
started?
end
def
refresh_jid_expiration
return
unless
jid
Gitlab
::
SidekiqStatus
.
set
(
jid
,
StuckImportJobsWorker
::
IMPORT_JOBS_EXPIRATION
)
end
def
self
.
jid_by
(
project_id
:,
status
:)
select
(
:jid
).
with_status
(
status
).
find_by
(
project_id:
project_id
)
end
end
app/models/project_import_state.rb
View file @
488afee0
...
...
@@ -2,6 +2,7 @@
class
ProjectImportState
<
ApplicationRecord
include
AfterCommitQueue
include
ImportState
::
SidekiqJobTracker
self
.
table_name
=
"project_mirror_data"
...
...
@@ -88,20 +89,6 @@ class ProjectImportState < ApplicationRecord
# import? does SQL work so only run it if it looks like there's an import running
status
==
'started'
&&
project
.
import?
end
# Refreshes the expiration time of the associated import job ID.
#
# This method can be used by asynchronous importers to refresh the status,
# preventing the StuckImportJobsWorker from marking the import as failed.
def
refresh_jid_expiration
return
unless
jid
Gitlab
::
SidekiqStatus
.
set
(
jid
,
StuckImportJobsWorker
::
IMPORT_JOBS_EXPIRATION
)
end
def
self
.
jid_by
(
project_id
:,
status
:)
select
(
:jid
).
with_status
(
status
).
find_by
(
project_id:
project_id
)
end
end
ProjectImportState
.
prepend_if_ee
(
'EE::ProjectImportState'
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment