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
f2b99bfb
Commit
f2b99bfb
authored
Jan 28, 2022
by
Heinrich Lee Yu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make epic service consistent
Use an ActiveRecord::Relation as positioning_scope
parent
88512cef
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
8 deletions
+14
-8
ee/app/services/epics/update_service.rb
ee/app/services/epics/update_service.rb
+14
-8
No files found.
ee/app/services/epics/update_service.rb
View file @
f2b99bfb
...
...
@@ -2,6 +2,8 @@
module
Epics
class
UpdateService
<
Epics
::
BaseService
include
Gitlab
::
Utils
::
StrongMemoize
EPIC_DATE_FIELDS
=
%I[
start_date_fixed
start_date_is_fixed
...
...
@@ -109,7 +111,7 @@ module Epics
fill_missing_positions_before
epic_board_position
=
issuable_for_positioning
(
epic
.
id
,
epic_board_id
,
create_missing:
true
)
epic_board_position
=
issuable_for_positioning
(
epic
.
id
,
positioning_scope
,
create_missing:
true
)
handle_move_between_ids
(
epic_board_position
)
epic_board_position
.
save!
...
...
@@ -117,14 +119,14 @@ module Epics
# we want to create missing only for the epic being moved
# other records are handled by PositionCreateService
def
issuable_for_positioning
(
id
,
board_id
,
create_missing:
false
)
def
issuable_for_positioning
(
id
,
positioning_scope
,
create_missing:
false
)
return
unless
id
position
=
Boards
::
EpicBoardPosition
.
find_by_epic_id_and_epic_board_id
(
id
,
board_
id
)
position
=
positioning_scope
.
find_by_epic_id
(
id
)
return
position
if
position
Boards
::
EpicBoardPosition
.
create!
(
epic_id:
id
,
epic_board_id:
board_
id
)
if
create_missing
positioning_scope
.
create!
(
epic_id:
id
)
if
create_missing
end
def
fill_missing_positions_before
...
...
@@ -134,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
,
epic_board_id
)
return
if
issuable_for_positioning
(
before_id
,
positioning_scope
)
service_params
=
{
board_id:
epic_board_id
,
...
...
@@ -145,11 +147,15 @@ module Epics
Boards
::
Epics
::
PositionCreateService
.
new
(
board_group
,
current_user
,
service_params
).
execute
end
def
epic_board_id
params
[
:board_id
]
def
positioning_scope
Boards
::
EpicBoardPosition
.
where
(
epic_board_id:
epic_board_id
)
# rubocop: disable CodeReuse/ActiveRecord
end
alias_method
:positioning_scope
,
:epic_board_id
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?
...
...
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