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
fc73f551
Commit
fc73f551
authored
Dec 19, 2018
by
Mark Chao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update progress checker
Check presence of type of jobs in queue
parent
d3458463
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
23 deletions
+30
-23
ee/lib/gitlab/background_migration/migrate_approver_to_approval_rules_check_progress.rb
...tion/migrate_approver_to_approval_rules_check_progress.rb
+5
-23
ee/spec/lib/gitlab/background_migration/migrate_approver_to_approval_rules_check_progress_spec.rb
...migrate_approver_to_approval_rules_check_progress_spec.rb
+25
-0
No files found.
ee/lib/gitlab/background_migration/migrate_approver_to_approval_rules_check_progress.rb
View file @
fc73f551
...
@@ -6,35 +6,17 @@ module Gitlab
...
@@ -6,35 +6,17 @@ module Gitlab
RESCHEDULE_DELAY
=
1
.
day
RESCHEDULE_DELAY
=
1
.
day
def
perform
def
perform
if
remaining
(
'MergeRequest'
)
==
0
&&
remaining
(
'Project'
)
==
0
if
remaining?
Feature
.
enable
(
:approval_rule
)
else
BackgroundMigrationWorker
.
perform_in
(
RESCHEDULE_DELAY
,
self
.
class
.
name
)
BackgroundMigrationWorker
.
perform_in
(
RESCHEDULE_DELAY
,
self
.
class
.
name
)
else
Feature
.
enable
(
:approval_rule
)
end
end
end
end
private
private
def
remaining
(
class_name
)
def
remaining?
target_type
=
ActiveRecord
::
Base
.
connection
.
quote
(
class_name
)
Gitlab
::
BackgroundMigration
.
exists?
(
'MigrateApproverToApprovalRulesInBatch'
)
sql_old_schema
=
<<-
SQL
.
strip_heredoc
SELECT count(*) FROM (
SELECT target_id FROM "approvers" WHERE "approvers"."target_type" =
#{
target_type
}
UNION
SELECT target_id FROM "approver_groups" WHERE "approver_groups"."target_type" =
#{
target_type
}
) AS target_count
SQL
sql_new_schema
=
<<-
SQL
.
strip_heredoc
SELECT count(distinct
#{
class_name
.
foreign_key
}
) from approval_
#{
class_name
.
underscore
}
_rules
SQL
count
(
sql_old_schema
)
-
count
(
sql_new_schema
)
end
def
count
(
sql
)
ActiveRecord
::
Base
.
connection
.
exec_query
(
sql
).
first
[
'count'
]
end
end
end
end
end
end
...
...
ee/spec/lib/gitlab/background_migration/migrate_approver_to_approval_rules_check_progress_spec.rb
0 → 100644
View file @
fc73f551
# frozen_string_literal: true
require
'spec_helper'
describe
Gitlab
::
BackgroundMigration
::
MigrateApproverToApprovalRulesCheckProgress
do
context
'when there is MigrateApproverToApprovalRulesInBatch jobs'
do
it
'reschedules check'
do
allow
(
Gitlab
::
BackgroundMigration
).
to
receive
(
:exists?
).
with
(
'MigrateApproverToApprovalRulesInBatch'
).
and_return
(
true
)
expect
(
BackgroundMigrationWorker
).
to
receive
(
:perform_in
).
with
(
described_class
::
RESCHEDULE_DELAY
,
described_class
.
name
)
described_class
.
new
.
perform
end
end
context
'when there is no more MigrateApproverToApprovalRulesInBatch jobs'
do
it
'enables feature'
do
allow
(
Gitlab
::
BackgroundMigration
).
to
receive
(
:exists?
).
with
(
'MigrateApproverToApprovalRulesInBatch'
).
and_return
(
false
)
expect
(
Feature
).
to
receive
(
:enable
).
and_return
(
:approval_rule
)
described_class
.
new
.
perform
end
end
end
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