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
f086dbf6
Commit
f086dbf6
authored
Mar 27, 2019
by
Nick Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a thin encapsulation around .pluck(:id)
parent
013f7cd2
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
19 additions
and
14 deletions
+19
-14
app/models/application_record.rb
app/models/application_record.rb
+8
-0
app/services/issuable_base_service.rb
app/services/issuable_base_service.rb
+1
-3
app/services/merge_requests/delete_non_latest_diffs_service.rb
...ervices/merge_requests/delete_non_latest_diffs_service.rb
+1
-3
app/services/milestones/promote_service.rb
app/services/milestones/promote_service.rb
+1
-3
app/services/quick_actions/interpret_service.rb
app/services/quick_actions/interpret_service.rb
+8
-5
No files found.
app/models/application_record.rb
View file @
f086dbf6
...
...
@@ -7,6 +7,14 @@ class ApplicationRecord < ActiveRecord::Base
where
(
id:
ids
)
end
def
self
.
id_not_in
(
ids
)
where
.
not
(
id:
ids
)
end
def
self
.
pluck_primary_key
where
(
nil
).
pluck
(
self
.
primary_key
)
end
def
self
.
safe_find_or_create_by!
(
*
args
)
safe_find_or_create_by
(
*
args
).
tap
do
|
record
|
record
.
validate!
unless
record
.
persisted?
...
...
app/services/issuable_base_service.rb
View file @
f086dbf6
...
...
@@ -76,13 +76,11 @@ class IssuableBaseService < BaseService
find_or_create_label_ids
end
# rubocop: disable CodeReuse/ActiveRecord
def
filter_labels_in_param
(
key
)
return
if
params
[
key
].
to_a
.
empty?
params
[
key
]
=
available_labels
.
where
(
id:
params
[
key
]).
pluck
(
:id
)
params
[
key
]
=
available_labels
.
id_in
(
params
[
key
]).
pluck_primary_key
end
# rubocop: enable CodeReuse/ActiveRecord
def
find_or_create_label_ids
labels
=
params
.
delete
(
:labels
)
...
...
app/services/merge_requests/delete_non_latest_diffs_service.rb
View file @
f086dbf6
...
...
@@ -8,15 +8,13 @@ module MergeRequests
@merge_request
=
merge_request
end
# rubocop: disable CodeReuse/ActiveRecord
def
execute
diffs
=
@merge_request
.
non_latest_diffs
.
with_files
diffs
.
each_batch
(
of:
BATCH_SIZE
)
do
|
relation
,
index
|
ids
=
relation
.
pluck
(
:id
)
.
map
{
|
id
|
[
id
]
}
ids
=
relation
.
pluck
_primary_key
.
map
{
|
id
|
[
id
]
}
DeleteDiffFilesWorker
.
bulk_perform_in
(
index
*
5
.
minutes
,
ids
)
end
end
# rubocop: enable CodeReuse/ActiveRecord
end
end
app/services/milestones/promote_service.rb
View file @
f086dbf6
...
...
@@ -26,17 +26,15 @@ module Milestones
private
# rubocop: disable CodeReuse/ActiveRecord
def
milestone_ids_for_merge
(
group_milestone
)
# Pluck need to be used here instead of select so the array of ids
# is persistent after old milestones gets deleted.
@milestone_ids_for_merge
||=
begin
search_params
=
{
title:
group_milestone
.
title
,
project_ids:
group_project_ids
,
state:
'all'
}
milestones
=
MilestonesFinder
.
new
(
search_params
).
execute
milestones
.
pluck
(
:id
)
milestones
.
pluck
_primary_key
end
end
# rubocop: enable CodeReuse/ActiveRecord
def
move_children_to_group_milestone
(
group_milestone
)
milestone_ids_for_merge
(
group_milestone
).
in_groups_of
(
100
,
false
)
do
|
milestone_ids
|
...
...
app/services/quick_actions/interpret_service.rb
View file @
f086dbf6
...
...
@@ -554,7 +554,7 @@ module QuickActions
current_user
.
can?
(
:"update_
#{
issuable
.
to_ability_name
}
"
,
issuable
)
&&
issuable
.
project
.
boards
.
count
==
1
end
# rubocop: disable CodeReuse/ActiveRecord
command
:board_move
do
|
target_list_name
|
label_ids
=
find_label_ids
(
target_list_name
)
...
...
@@ -562,14 +562,17 @@ module QuickActions
label_id
=
label_ids
.
first
# Ensure this label corresponds to a list on the board
next
unless
Label
.
on_project_boards
(
issuable
.
project_id
).
where
(
id:
label_id
).
exists?
next
unless
Label
.
on_project_boards
(
issuable
.
project_id
).
id_in
(
label_id
).
exists?
@updates
[
:remove_label_ids
]
=
issuable
.
labels
.
on_project_boards
(
issuable
.
project_id
)
.
id_not_in
(
label_id
)
.
pluck_primary_key
@updates
[
:remove_label_ids
]
=
issuable
.
labels
.
on_project_boards
(
issuable
.
project_id
).
where
.
not
(
id:
label_id
).
pluck
(
:id
)
@updates
[
:add_label_ids
]
=
[
label_id
]
end
end
# rubocop: enable CodeReuse/ActiveRecord
desc
'Mark this issue as a duplicate of another issue'
explanation
do
|
duplicate_reference
|
...
...
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