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
4786e97f
Commit
4786e97f
authored
Aug 26, 2021
by
Eulyeon Ko
Committed by
Eulyeon Ko
Aug 30, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Apply reviwer suggestions 2
Extract initialize_relative_positions into Board::Issues::ListService
parent
2a9bdd55
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
10 deletions
+57
-10
app/controllers/boards/issues_controller.rb
app/controllers/boards/issues_controller.rb
+1
-3
app/graphql/resolvers/board_list_issues_resolver.rb
app/graphql/resolvers/board_list_issues_resolver.rb
+1
-7
app/services/boards/issues/list_service.rb
app/services/boards/issues/list_service.rb
+8
-0
spec/services/boards/issues/list_service_spec.rb
spec/services/boards/issues/list_service_spec.rb
+47
-0
No files found.
app/controllers/boards/issues_controller.rb
View file @
4786e97f
...
@@ -27,9 +27,7 @@ module Boards
...
@@ -27,9 +27,7 @@ module Boards
list_service
=
Boards
::
Issues
::
ListService
.
new
(
board_parent
,
current_user
,
filter_params
)
list_service
=
Boards
::
Issues
::
ListService
.
new
(
board_parent
,
current_user
,
filter_params
)
issues
=
issues_from
(
list_service
)
issues
=
issues_from
(
list_service
)
if
Gitlab
::
Database
.
read_write?
&&
!
board
.
disabled_for?
(
current_user
)
::
Boards
::
Issues
::
ListService
.
initialize_relative_positions
(
board
,
current_user
,
issues
)
Issue
.
move_nulls_to_end
(
issues
)
end
render_issues
(
issues
,
list_service
.
metadata
)
render_issues
(
issues
,
list_service
.
metadata
)
end
end
...
...
app/graphql/resolvers/board_list_issues_resolver.rb
View file @
4786e97f
...
@@ -17,17 +17,11 @@ module Resolvers
...
@@ -17,17 +17,11 @@ module Resolvers
service
=
::
Boards
::
Issues
::
ListService
.
new
(
list
.
board
.
resource_parent
,
context
[
:current_user
],
filter_params
)
service
=
::
Boards
::
Issues
::
ListService
.
new
(
list
.
board
.
resource_parent
,
context
[
:current_user
],
filter_params
)
pagination_connections
=
Gitlab
::
Graphql
::
Pagination
::
Keyset
::
Connection
.
new
(
service
.
execute
)
pagination_connections
=
Gitlab
::
Graphql
::
Pagination
::
Keyset
::
Connection
.
new
(
service
.
execute
)
initialize_relative_positions
(
pagination_connections
.
items
,
list
.
board
)
::
Boards
::
Issues
::
ListService
.
initialize_relative_positions
(
list
.
board
,
current_user
,
pagination_connections
.
items
)
pagination_connections
pagination_connections
end
end
def
initialize_relative_positions
(
issues
,
board
)
if
Gitlab
::
Database
.
read_write?
&&
!
board
.
disabled_for?
(
current_user
)
Issue
.
move_nulls_to_end
(
issues
)
end
end
# https://gitlab.com/gitlab-org/gitlab/-/issues/235681
# https://gitlab.com/gitlab-org/gitlab/-/issues/235681
def
self
.
complexity_multiplier
(
args
)
def
self
.
complexity_multiplier
(
args
)
0.005
0.005
...
...
app/services/boards/issues/list_service.rb
View file @
4786e97f
...
@@ -9,6 +9,14 @@ module Boards
...
@@ -9,6 +9,14 @@ module Boards
IssuesFinder
.
valid_params
IssuesFinder
.
valid_params
end
end
# It is a class method because we cannot apply it
# prior to knowing how many items should be fetched for a list.
def
self
.
initialize_relative_positions
(
board
,
current_user
,
issues
)
if
Gitlab
::
Database
.
read_write?
&&
!
board
.
disabled_for?
(
current_user
)
Issue
.
move_nulls_to_end
(
issues
)
end
end
private
private
def
order
(
items
)
def
order
(
items
)
...
...
spec/services/boards/issues/list_service_spec.rb
View file @
4786e97f
...
@@ -139,4 +139,51 @@ RSpec.describe Boards::Issues::ListService do
...
@@ -139,4 +139,51 @@ RSpec.describe Boards::Issues::ListService do
end
end
# rubocop: enable RSpec/MultipleMemoizedHelpers
# rubocop: enable RSpec/MultipleMemoizedHelpers
end
end
describe
'.initialize_relative_positions'
do
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:project
)
{
create
(
:project
,
:empty_repo
)
}
let_it_be
(
:board
)
{
create
(
:board
,
project:
project
)
}
let_it_be
(
:backlog
)
{
create
(
:backlog_list
,
board:
board
)
}
let
(
:issue
)
{
create
(
:issue
,
project:
project
,
relative_position:
nil
)
}
context
"when 'Gitlab::Database::read_write?' is true"
do
before
do
allow
(
Gitlab
::
Database
).
to
receive
(
:read_write?
).
and_return
(
true
)
end
context
'user cannot move issues'
do
it
'does not initialize the relative positions of issues'
do
described_class
.
initialize_relative_positions
(
board
,
user
,
[
issue
])
expect
(
issue
.
relative_position
).
to
eq
nil
end
end
context
'user can move issues'
do
before
do
project
.
add_developer
(
user
)
end
it
'initializes the relative positions of issues'
do
described_class
.
initialize_relative_positions
(
board
,
user
,
[
issue
])
expect
(
issue
.
relative_position
).
not_to
eq
nil
end
end
end
context
"when 'Gitlab::Database::read_write?' is false"
do
before
do
allow
(
Gitlab
::
Database
).
to
receive
(
:read_write?
).
and_return
(
false
)
end
it
'does not initialize the relative positions of issues'
do
described_class
.
initialize_relative_positions
(
board
,
user
,
[
issue
])
expect
(
issue
.
relative_position
).
to
eq
nil
end
end
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