BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
b72af2b9
Commit
b72af2b9
authored
Jan 05, 2018
by
Sean McGivern
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'ce-backport=reorder-issues' into 'master'
CE Backport of reordering issues in epics See merge request gitlab-org/gitlab-ce!16247
parents
ae46ceaa
153ea183
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
49 additions
and
61 deletions
+49
-61
relative_positioning.rb
app/models/concerns/relative_positioning.rb
+11
-7
issue.rb
app/models/issue.rb
+6
-0
prepare_untracked_uploads_spec.rb
...ab/background_migration/prepare_untracked_uploads_spec.rb
+1
-12
migrate_stage_id_reference_in_background_spec.rb
...grations/migrate_stage_id_reference_in_background_spec.rb
+3
-3
migrate_stages_statuses_spec.rb
spec/migrations/migrate_stages_statuses_spec.rb
+3
-3
schedule_create_gpg_key_subkeys_from_gpg_keys_spec.rb
...ons/schedule_create_gpg_key_subkeys_from_gpg_keys_spec.rb
+0
-12
schedule_merge_request_diff_migrations_spec.rb
...migrations/schedule_merge_request_diff_migrations_spec.rb
+3
-3
schedule_merge_request_diff_migrations_take_two_spec.rb
...s/schedule_merge_request_diff_migrations_take_two_spec.rb
+3
-3
schedule_merge_request_latest_merge_request_diff_id_migrations_spec.rb
...e_request_latest_merge_request_diff_id_migrations_spec.rb
+3
-3
schedule_populate_merge_request_metrics_with_events_data_spec.rb
...e_populate_merge_request_metrics_with_events_data_spec.rb
+2
-2
track_untracked_uploads_spec.rb
spec/migrations/track_untracked_uploads_spec.rb
+0
-12
background_migrations_matchers.rb
spec/support/background_migrations_matchers.rb
+14
-1
No files found.
app/models/concerns/relative_positioning.rb
View file @
b72af2b9
...
...
@@ -10,12 +10,12 @@ module RelativePositioning
after_save
:save_positionable_neighbours
end
def
project_ids
[
project
.
id
]
def
min_relative_position
self
.
class
.
in_parents
(
parent_ids
).
minimum
(
:relative_position
)
end
def
max_relative_position
self
.
class
.
in_p
rojects
(
projec
t_ids
).
maximum
(
:relative_position
)
self
.
class
.
in_p
arents
(
paren
t_ids
).
maximum
(
:relative_position
)
end
def
prev_relative_position
...
...
@@ -23,7 +23,7 @@ module RelativePositioning
if
self
.
relative_position
prev_pos
=
self
.
class
.
in_p
rojects
(
projec
t_ids
)
.
in_p
arents
(
paren
t_ids
)
.
where
(
'relative_position < ?'
,
self
.
relative_position
)
.
maximum
(
:relative_position
)
end
...
...
@@ -36,7 +36,7 @@ module RelativePositioning
if
self
.
relative_position
next_pos
=
self
.
class
.
in_p
rojects
(
projec
t_ids
)
.
in_p
arents
(
paren
t_ids
)
.
where
(
'relative_position > ?'
,
self
.
relative_position
)
.
minimum
(
:relative_position
)
end
...
...
@@ -63,7 +63,7 @@ module RelativePositioning
pos_after
=
before
.
next_relative_position
if
before
.
shift_after?
issue_to_move
=
self
.
class
.
in_p
rojects
(
projec
t_ids
).
find_by!
(
relative_position:
pos_after
)
issue_to_move
=
self
.
class
.
in_p
arents
(
paren
t_ids
).
find_by!
(
relative_position:
pos_after
)
issue_to_move
.
move_after
@positionable_neighbours
=
[
issue_to_move
]
# rubocop:disable Gitlab/ModuleWithInstanceVariables
...
...
@@ -78,7 +78,7 @@ module RelativePositioning
pos_before
=
after
.
prev_relative_position
if
after
.
shift_before?
issue_to_move
=
self
.
class
.
in_p
rojects
(
projec
t_ids
).
find_by!
(
relative_position:
pos_before
)
issue_to_move
=
self
.
class
.
in_p
arents
(
paren
t_ids
).
find_by!
(
relative_position:
pos_before
)
issue_to_move
.
move_before
@positionable_neighbours
=
[
issue_to_move
]
# rubocop:disable Gitlab/ModuleWithInstanceVariables
...
...
@@ -92,6 +92,10 @@ module RelativePositioning
self
.
relative_position
=
position_between
(
max_relative_position
||
START_POSITION
,
MAX_POSITION
)
end
def
move_to_start
self
.
relative_position
=
position_between
(
min_relative_position
||
START_POSITION
,
MIN_POSITION
)
end
# Indicates if there is an issue that should be shifted to free the place
def
shift_after?
next_pos
=
next_relative_position
...
...
app/models/issue.rb
View file @
b72af2b9
...
...
@@ -35,6 +35,8 @@ class Issue < ActiveRecord::Base
validates
:project
,
presence:
true
alias_attribute
:parent_ids
,
:project_id
scope
:in_projects
,
->
(
project_ids
)
{
where
(
project_id:
project_ids
)
}
scope
:assigned
,
->
{
where
(
'EXISTS (SELECT TRUE FROM issue_assignees WHERE issue_id = issues.id)'
)
}
...
...
@@ -78,6 +80,10 @@ class Issue < ActiveRecord::Base
acts_as_paranoid
class
<<
self
alias_method
:in_parents
,
:in_projects
end
def
self
.
reference_prefix
'#'
end
...
...
spec/lib/gitlab/background_migration/prepare_untracked_uploads_spec.rb
View file @
b72af2b9
...
...
@@ -2,21 +2,10 @@ require 'spec_helper'
describe
Gitlab
::
BackgroundMigration
::
PrepareUntrackedUploads
,
:sidekiq
do
include
TrackUntrackedUploadsHelpers
include
MigrationsHelpers
let!
(
:untracked_files_for_uploads
)
{
described_class
::
UntrackedFile
}
matcher
:be_scheduled_migration
do
|*
expected
|
match
do
|
migration
|
BackgroundMigrationWorker
.
jobs
.
any?
do
|
job
|
job
[
'args'
]
==
[
migration
,
expected
]
end
end
failure_message
do
|
migration
|
"Migration `
#{
migration
}
` with args `
#{
expected
.
inspect
}
` not scheduled!"
end
end
before
do
DatabaseCleaner
.
clean
...
...
spec/migrations/migrate_stage_id_reference_in_background_spec.rb
View file @
b72af2b9
...
...
@@ -35,9 +35,9 @@ describe MigrateStageIdReferenceInBackground, :migration, :sidekiq do
Timecop
.
freeze
do
migrate!
expect
(
described_class
::
MIGRATION
).
to
be_scheduled_migration
(
2
.
minutes
,
1
,
2
)
expect
(
described_class
::
MIGRATION
).
to
be_scheduled_migration
(
2
.
minutes
,
3
,
3
)
expect
(
described_class
::
MIGRATION
).
to
be_scheduled_migration
(
4
.
minutes
,
4
,
5
)
expect
(
described_class
::
MIGRATION
).
to
be_scheduled_
delayed_
migration
(
2
.
minutes
,
1
,
2
)
expect
(
described_class
::
MIGRATION
).
to
be_scheduled_
delayed_
migration
(
2
.
minutes
,
3
,
3
)
expect
(
described_class
::
MIGRATION
).
to
be_scheduled_
delayed_
migration
(
4
.
minutes
,
4
,
5
)
expect
(
BackgroundMigrationWorker
.
jobs
.
size
).
to
eq
3
end
end
...
...
spec/migrations/migrate_stages_statuses_spec.rb
View file @
b72af2b9
...
...
@@ -50,9 +50,9 @@ describe MigrateStagesStatuses, :migration do
Timecop
.
freeze
do
migrate!
expect
(
described_class
::
MIGRATION
).
to
be_scheduled_migration
(
5
.
minutes
,
1
,
1
)
expect
(
described_class
::
MIGRATION
).
to
be_scheduled_migration
(
5
.
minutes
,
2
,
2
)
expect
(
described_class
::
MIGRATION
).
to
be_scheduled_migration
(
10
.
minutes
,
3
,
3
)
expect
(
described_class
::
MIGRATION
).
to
be_scheduled_
delayed_
migration
(
5
.
minutes
,
1
,
1
)
expect
(
described_class
::
MIGRATION
).
to
be_scheduled_
delayed_
migration
(
5
.
minutes
,
2
,
2
)
expect
(
described_class
::
MIGRATION
).
to
be_scheduled_
delayed_
migration
(
10
.
minutes
,
3
,
3
)
expect
(
BackgroundMigrationWorker
.
jobs
.
size
).
to
eq
3
end
end
...
...
spec/migrations/schedule_create_gpg_key_subkeys_from_gpg_keys_spec.rb
View file @
b72af2b9
...
...
@@ -2,18 +2,6 @@ require 'spec_helper'
require
Rails
.
root
.
join
(
'db'
,
'post_migrate'
,
'20171005130944_schedule_create_gpg_key_subkeys_from_gpg_keys'
)
describe
ScheduleCreateGpgKeySubkeysFromGpgKeys
,
:migration
,
:sidekiq
do
matcher
:be_scheduled_migration
do
|*
expected
|
match
do
|
migration
|
BackgroundMigrationWorker
.
jobs
.
any?
do
|
job
|
job
[
'args'
]
==
[
migration
,
expected
]
end
end
failure_message
do
|
migration
|
"Migration `
#{
migration
}
` with args `
#{
expected
.
inspect
}
` not scheduled!"
end
end
before
do
create
(
:gpg_key
,
id:
1
,
key:
GpgHelpers
::
User1
.
public_key
)
create
(
:gpg_key
,
id:
2
,
key:
GpgHelpers
::
User3
.
public_key
)
...
...
spec/migrations/schedule_merge_request_diff_migrations_spec.rb
View file @
b72af2b9
...
...
@@ -24,9 +24,9 @@ describe ScheduleMergeRequestDiffMigrations, :migration, :sidekiq do
Timecop
.
freeze
do
migrate!
expect
(
described_class
::
MIGRATION
).
to
be_scheduled_migration
(
5
.
minutes
,
1
,
1
)
expect
(
described_class
::
MIGRATION
).
to
be_scheduled_migration
(
10
.
minutes
,
2
,
2
)
expect
(
described_class
::
MIGRATION
).
to
be_scheduled_migration
(
15
.
minutes
,
4
,
4
)
expect
(
described_class
::
MIGRATION
).
to
be_scheduled_
delayed_
migration
(
5
.
minutes
,
1
,
1
)
expect
(
described_class
::
MIGRATION
).
to
be_scheduled_
delayed_
migration
(
10
.
minutes
,
2
,
2
)
expect
(
described_class
::
MIGRATION
).
to
be_scheduled_
delayed_
migration
(
15
.
minutes
,
4
,
4
)
expect
(
BackgroundMigrationWorker
.
jobs
.
size
).
to
eq
3
end
end
...
...
spec/migrations/schedule_merge_request_diff_migrations_take_two_spec.rb
View file @
b72af2b9
...
...
@@ -24,9 +24,9 @@ describe ScheduleMergeRequestDiffMigrationsTakeTwo, :migration, :sidekiq do
Timecop
.
freeze
do
migrate!
expect
(
described_class
::
MIGRATION
).
to
be_scheduled_migration
(
10
.
minutes
,
1
,
1
)
expect
(
described_class
::
MIGRATION
).
to
be_scheduled_migration
(
20
.
minutes
,
2
,
2
)
expect
(
described_class
::
MIGRATION
).
to
be_scheduled_migration
(
30
.
minutes
,
4
,
4
)
expect
(
described_class
::
MIGRATION
).
to
be_scheduled_
delayed_
migration
(
10
.
minutes
,
1
,
1
)
expect
(
described_class
::
MIGRATION
).
to
be_scheduled_
delayed_
migration
(
20
.
minutes
,
2
,
2
)
expect
(
described_class
::
MIGRATION
).
to
be_scheduled_
delayed_
migration
(
30
.
minutes
,
4
,
4
)
expect
(
BackgroundMigrationWorker
.
jobs
.
size
).
to
eq
3
end
end
...
...
spec/migrations/schedule_merge_request_latest_merge_request_diff_id_migrations_spec.rb
View file @
b72af2b9
...
...
@@ -44,9 +44,9 @@ describe ScheduleMergeRequestLatestMergeRequestDiffIdMigrations, :migration, :si
Timecop
.
freeze
do
migrate!
expect
(
described_class
::
MIGRATION
).
to
be_scheduled_migration
(
5
.
minutes
,
merge_request_1
.
id
,
merge_request_1
.
id
)
expect
(
described_class
::
MIGRATION
).
to
be_scheduled_migration
(
10
.
minutes
,
merge_request_2
.
id
,
merge_request_2
.
id
)
expect
(
described_class
::
MIGRATION
).
to
be_scheduled_migration
(
15
.
minutes
,
merge_request_4
.
id
,
merge_request_4
.
id
)
expect
(
described_class
::
MIGRATION
).
to
be_scheduled_
delayed_
migration
(
5
.
minutes
,
merge_request_1
.
id
,
merge_request_1
.
id
)
expect
(
described_class
::
MIGRATION
).
to
be_scheduled_
delayed_
migration
(
10
.
minutes
,
merge_request_2
.
id
,
merge_request_2
.
id
)
expect
(
described_class
::
MIGRATION
).
to
be_scheduled_
delayed_
migration
(
15
.
minutes
,
merge_request_4
.
id
,
merge_request_4
.
id
)
expect
(
BackgroundMigrationWorker
.
jobs
.
size
).
to
eq
3
end
end
...
...
spec/migrations/schedule_populate_merge_request_metrics_with_events_data_spec.rb
View file @
b72af2b9
...
...
@@ -12,10 +12,10 @@ describe SchedulePopulateMergeRequestMetricsWithEventsData, :migration, :sidekiq
migrate!
expect
(
described_class
::
MIGRATION
)
.
to
be_scheduled_migration
(
10
.
minutes
,
mrs
.
first
.
id
,
mrs
.
second
.
id
)
.
to
be_scheduled_
delayed_
migration
(
10
.
minutes
,
mrs
.
first
.
id
,
mrs
.
second
.
id
)
expect
(
described_class
::
MIGRATION
)
.
to
be_scheduled_migration
(
20
.
minutes
,
mrs
.
third
.
id
,
mrs
.
third
.
id
)
.
to
be_scheduled_
delayed_
migration
(
20
.
minutes
,
mrs
.
third
.
id
,
mrs
.
third
.
id
)
expect
(
BackgroundMigrationWorker
.
jobs
.
size
).
to
eq
(
2
)
end
...
...
spec/migrations/track_untracked_uploads_spec.rb
View file @
b72af2b9
...
...
@@ -4,18 +4,6 @@ require Rails.root.join('db', 'post_migrate', '20171103140253_track_untracked_up
describe
TrackUntrackedUploads
,
:migration
,
:sidekiq
do
include
TrackUntrackedUploadsHelpers
matcher
:be_scheduled_migration
do
match
do
|
migration
|
BackgroundMigrationWorker
.
jobs
.
any?
do
|
job
|
job
[
'args'
]
==
[
migration
]
end
end
failure_message
do
|
migration
|
"Migration `
#{
migration
}
` with args `
#{
expected
.
inspect
}
` not scheduled!"
end
end
it
'correctly schedules the follow-up background migration'
do
Sidekiq
::
Testing
.
fake!
do
migrate!
...
...
spec/support/background_migrations_matchers.rb
View file @
b72af2b9
RSpec
::
Matchers
.
define
:be_scheduled_migration
do
|
delay
,
*
expected
|
RSpec
::
Matchers
.
define
:be_scheduled_
delayed_
migration
do
|
delay
,
*
expected
|
match
do
|
migration
|
BackgroundMigrationWorker
.
jobs
.
any?
do
|
job
|
job
[
'args'
]
==
[
migration
,
expected
]
&&
...
...
@@ -11,3 +11,16 @@ RSpec::Matchers.define :be_scheduled_migration do |delay, *expected|
'not scheduled in expected time!'
end
end
RSpec
::
Matchers
.
define
:be_scheduled_migration
do
|*
expected
|
match
do
|
migration
|
BackgroundMigrationWorker
.
jobs
.
any?
do
|
job
|
args
=
job
[
'args'
].
size
==
1
?
[
BackgroundMigrationWorker
.
jobs
[
0
][
'args'
][
0
],
[]]
:
job
[
'args'
]
args
==
[
migration
,
expected
]
end
end
failure_message
do
|
migration
|
"Migration `
#{
migration
}
` with args `
#{
expected
.
inspect
}
` not scheduled!"
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