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
f4364dd3
Commit
f4364dd3
authored
Feb 04, 2022
by
Heinrich Lee Yu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor positioning_scope method
Change the code so that this is only used within handle_move_between_ids.
parent
f2b99bfb
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
44 deletions
+22
-44
app/services/issuable_base_service.rb
app/services/issuable_base_service.rb
+2
-0
app/services/issues/reorder_service.rb
app/services/issues/reorder_service.rb
+10
-18
app/services/issues/update_service.rb
app/services/issues/update_service.rb
+0
-6
ee/app/services/epics/update_service.rb
ee/app/services/epics/update_service.rb
+10
-20
No files found.
app/services/issuable_base_service.rb
View file @
f4364dd3
...
...
@@ -496,6 +496,8 @@ class IssuableBaseService < ::BaseProjectService
after_id
,
before_id
=
params
.
delete
(
:move_between_ids
)
positioning_scope
=
issuable_position
.
class
.
relative_positioning_query_base
(
issuable_position
)
issuable_before
=
issuable_for_positioning
(
before_id
,
positioning_scope
)
issuable_after
=
issuable_for_positioning
(
after_id
,
positioning_scope
)
...
...
app/services/issues/reorder_service.rb
View file @
f4364dd3
...
...
@@ -2,13 +2,13 @@
module
Issues
class
ReorderService
<
Issues
::
BaseService
include
Gitlab
::
Utils
::
StrongMemoize
def
execute
(
issue
)
return
false
unless
can?
(
current_user
,
:update_issue
,
issue
)
return
false
unless
move_between_ids
attrs
=
issue_params
return
false
if
attrs
.
empty?
update
(
issue
,
attrs
)
update
(
issue
,
{
move_between_ids:
move_between_ids
})
end
private
...
...
@@ -19,22 +19,14 @@ module Issues
false
end
def
issue_params
attrs
=
{}
if
move_between_ids
attrs
[
:move_between_ids
]
=
move_between_ids
end
attrs
end
def
move_between_ids
ids
=
[
params
[
:move_after_id
],
params
[
:move_before_id
]]
.
map
(
&
:to_i
)
.
map
{
|
m
|
m
>
0
?
m
:
nil
}
strong_memoize
(
:move_between_ids
)
do
ids
=
[
params
[
:move_after_id
],
params
[
:move_before_id
]]
.
map
(
&
:to_i
)
.
map
{
|
m
|
m
>
0
?
m
:
nil
}
ids
.
any?
?
ids
:
nil
ids
.
any?
?
ids
:
nil
end
end
end
end
app/services/issues/update_service.rb
View file @
f4364dd3
...
...
@@ -13,8 +13,6 @@ module Issues
end
def
execute
(
issue
)
@issue
=
issue
handle_move_between_ids
(
issue
)
change_issue_duplicate
(
issue
)
...
...
@@ -227,10 +225,6 @@ module Issues
issue
if
can?
(
current_user
,
:update_issue
,
issue
)
end
def
positioning_scope
Issue
.
relative_positioning_query_base
(
@issue
)
end
def
create_confidentiality_note
(
issue
)
SystemNoteService
.
change_issue_confidentiality
(
issue
,
issue
.
project
,
current_user
)
end
...
...
ee/app/services/epics/update_service.rb
View file @
f4364dd3
...
...
@@ -11,6 +11,8 @@ module Epics
due_date_is_fixed
]
.
freeze
attr_reader
:epic_board_id
def
execute
(
epic
)
reposition_on_board
(
epic
)
...
...
@@ -106,27 +108,25 @@ module Epics
end
def
reposition_on_board
(
epic
)
@epic_board_id
=
params
.
delete
(
:board_id
)
return
unless
params
[
:move_between_ids
]
return
unless
epic_board_id
fill_missing_positions_before
epic_board_position
=
issuable_for_positioning
(
epic
.
id
,
positioning_scope
,
create_missing:
true
)
# we want to create missing only for the epic being moved
# other records are handled by PositionCreateService
epic_board_position
=
Boards
::
EpicBoardPosition
.
find_or_create_by!
(
epic_board_id:
epic_board_id
,
epic_id:
epic
.
id
)
# rubocop: disable CodeReuse/ActiveRecord
handle_move_between_ids
(
epic_board_position
)
epic_board_position
.
save!
end
# we want to create missing only for the epic being moved
# other records are handled by PositionCreateService
def
issuable_for_positioning
(
id
,
positioning_scope
,
create_missing:
false
)
def
issuable_for_positioning
(
id
,
positioning_scope
)
return
unless
id
position
=
positioning_scope
.
find_by_epic_id
(
id
)
return
position
if
position
positioning_scope
.
create!
(
epic_id:
id
)
if
create_missing
positioning_scope
.
find_by_epic_id
(
id
)
end
def
fill_missing_positions_before
...
...
@@ -136,7 +136,7 @@ module Epics
return
unless
before_id
# if position for the epic above exists we don't need to create positioning records
return
if
issuable_for_positioning
(
before_id
,
positioning_scope
)
return
if
Boards
::
EpicBoardPosition
.
exists?
(
epic_board_id:
epic_board_id
,
epic_id:
before_id
)
# rubocop: disable CodeReuse/ActiveRecord
service_params
=
{
board_id:
epic_board_id
,
...
...
@@ -147,16 +147,6 @@ module Epics
Boards
::
Epics
::
PositionCreateService
.
new
(
board_group
,
current_user
,
service_params
).
execute
end
def
positioning_scope
Boards
::
EpicBoardPosition
.
where
(
epic_board_id:
epic_board_id
)
# rubocop: disable CodeReuse/ActiveRecord
end
def
epic_board_id
strong_memoize
(
:epic_board_id
)
do
params
.
delete
(
:board_id
)
end
end
def
saved_change_to_epic_dates?
(
epic
)
(
epic
.
saved_changes
.
keys
.
map
(
&
:to_sym
)
&
EPIC_DATE_FIELDS
).
present?
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