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
0
Merge Requests
0
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
Tatuya Kamada
gitlab-ce
Commits
32538def
Commit
32538def
authored
Mar 03, 2017
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Issue sorting on board] Addressing review issues
parent
39db04bb
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
12 additions
and
32 deletions
+12
-32
app/models/concerns/relative_positioning.rb
app/models/concerns/relative_positioning.rb
+7
-0
app/services/boards/issues/move_service.rb
app/services/boards/issues/move_service.rb
+2
-4
spec/lib/gitlab/import_export/safe_model_attributes.yml
spec/lib/gitlab/import_export/safe_model_attributes.yml
+1
-0
spec/services/boards/issues/list_service_spec.rb
spec/services/boards/issues/list_service_spec.rb
+0
-26
spec/services/boards/issues/move_service_spec.rb
spec/services/boards/issues/move_service_spec.rb
+2
-2
No files found.
app/models/concerns/relative_positioning.rb
View file @
32538def
...
@@ -114,6 +114,13 @@ module RelativePositioning
...
@@ -114,6 +114,13 @@ module RelativePositioning
private
private
# This method takes two integer values (positions) and
# calculates some random position between them. The range is huge as
# the maximum integer value is 2147483647. Ideally, the calculated value would be
# exactly between those terminating values, but this will introduce possibility of a race condition
# so two or more issues can get the same value, we want to avoid that and we also want to avoid
# using a lock here. If we have two issues with distance more than one thousand, we are OK.
# Given the huge range of possible values that integer can fit we shoud never face a problem.
def
position_between
(
pos_before
,
pos_after
)
def
position_between
(
pos_before
,
pos_after
)
pos_before
||=
MIN_POSITION
pos_before
||=
MIN_POSITION
pos_after
||=
MAX_POSITION
pos_after
||=
MAX_POSITION
...
...
app/services/boards/issues/move_service.rb
View file @
32538def
...
@@ -68,11 +68,9 @@ module Boards
...
@@ -68,11 +68,9 @@ module Boards
end
end
def
move_between_iids
def
move_between_iids
move_after_iid
=
params
[
:move_after_iid
]
return
unless
params
[
:move_after_iid
]
||
params
[
:move_before_iid
]
move_before_iid
=
params
[
:move_before_iid
]
return
unless
move_after_iid
||
move_before_iid
[
move_after_iid
,
move_before_iid
]
[
params
[
:move_after_iid
],
params
[
:move_before_iid
]
]
end
end
end
end
end
end
...
...
spec/lib/gitlab/import_export/safe_model_attributes.yml
View file @
32538def
...
@@ -21,6 +21,7 @@ Issue:
...
@@ -21,6 +21,7 @@ Issue:
-
milestone_id
-
milestone_id
-
weight
-
weight
-
time_estimate
-
time_estimate
-
relative_position
Event
:
Event
:
-
id
-
id
-
target_type
-
target_type
...
...
spec/services/boards/issues/list_service_spec.rb
View file @
32538def
...
@@ -43,32 +43,6 @@ describe Boards::Issues::ListService, services: true do
...
@@ -43,32 +43,6 @@ describe Boards::Issues::ListService, services: true do
described_class
.
new
(
project
,
user
,
params
).
execute
described_class
.
new
(
project
,
user
,
params
).
execute
end
end
context
'sets default order to priority'
do
it
'returns opened issues when list id is missing'
do
params
=
{
board_id:
board
.
id
}
issues
=
described_class
.
new
(
project
,
user
,
params
).
execute
expect
(
issues
).
to
eq
[
opened_issue2
,
reopened_issue1
,
opened_issue1
]
end
it
'returns closed issues when listing issues from Done'
do
params
=
{
board_id:
board
.
id
,
id:
done
.
id
}
issues
=
described_class
.
new
(
project
,
user
,
params
).
execute
expect
(
issues
).
to
eq
[
closed_issue4
,
closed_issue2
,
closed_issue3
,
closed_issue1
]
end
it
'returns opened issues that have label list applied when listing issues from a label list'
do
params
=
{
board_id:
board
.
id
,
id:
list1
.
id
}
issues
=
described_class
.
new
(
project
,
user
,
params
).
execute
expect
(
issues
).
to
eq
[
list1_issue3
,
list1_issue1
,
list1_issue2
]
end
end
context
'with list that does not belong to the board'
do
context
'with list that does not belong to the board'
do
it
'raises an error'
do
it
'raises an error'
do
list
=
create
(
:list
)
list
=
create
(
:list
)
...
...
spec/services/boards/issues/move_service_spec.rb
View file @
32538def
...
@@ -94,9 +94,9 @@ describe Boards::Issues::MoveService, services: true do
...
@@ -94,9 +94,9 @@ describe Boards::Issues::MoveService, services: true do
end
end
it
'sorts issues'
do
it
'sorts issues'
do
issue
.
move_between
(
issue1
,
issue2
)
issue
.
move_between
!
(
issue1
,
issue2
)
params
.
merge!
move_after_iid:
issue
1
.
iid
,
move_before_iid:
issue2
.
iid
params
.
merge!
move_after_iid:
issue
.
iid
,
move_before_iid:
issue2
.
iid
described_class
.
new
(
project
,
user
,
params
).
execute
(
issue1
)
described_class
.
new
(
project
,
user
,
params
).
execute
(
issue1
)
...
...
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