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
Léo-Paul Géneau
gitlab-ce
Commits
db80db79
Commit
db80db79
authored
Oct 26, 2018
by
Jasper Maes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace deprecated uniq on a Relation with distinct
parent
1815aa56
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
11 additions
and
6 deletions
+11
-6
app/models/milestone.rb
app/models/milestone.rb
+1
-1
app/models/user.rb
app/models/user.rb
+1
-1
app/services/delete_merged_branches_service.rb
app/services/delete_merged_branches_service.rb
+2
-2
app/services/labels/transfer_service.rb
app/services/labels/transfer_service.rb
+1
-1
changelogs/unreleased/rails5-deprecated-uniq.yml
changelogs/unreleased/rails5-deprecated-uniq.yml
+5
-0
lib/gitlab/contributions_calendar.rb
lib/gitlab/contributions_calendar.rb
+1
-1
No files found.
app/models/milestone.rb
View file @
db80db79
...
...
@@ -145,7 +145,7 @@ class Milestone < ActiveRecord::Base
end
def
participants
User
.
joins
(
assigned_issues: :milestone
).
where
(
"milestones.id = ?"
,
id
).
uniq
User
.
joins
(
assigned_issues: :milestone
).
where
(
"milestones.id = ?"
,
id
).
distinct
end
def
self
.
sort_by_attribute
(
method
)
...
...
app/models/user.rb
View file @
db80db79
...
...
@@ -1138,7 +1138,7 @@ class User < ActiveRecord::Base
events
=
Event
.
select
(
:project_id
)
.
contributions
.
where
(
author_id:
self
)
.
where
(
"created_at > ?"
,
Time
.
now
-
1
.
year
)
.
uniq
.
distinct
.
reorder
(
nil
)
Project
.
where
(
id:
events
)
...
...
app/services/delete_merged_branches_service.rb
View file @
db80db79
...
...
@@ -24,8 +24,8 @@ class DeleteMergedBranchesService < BaseService
# rubocop: disable CodeReuse/ActiveRecord
def
merge_request_branch_names
# reorder(nil) is necessary for SELECT DISTINCT because default scope adds an ORDER BY
source_names
=
project
.
origin_merge_requests
.
opened
.
reorder
(
nil
).
uniq
.
pluck
(
:source_branch
)
target_names
=
project
.
merge_requests
.
opened
.
reorder
(
nil
).
uniq
.
pluck
(
:target_branch
)
source_names
=
project
.
origin_merge_requests
.
opened
.
reorder
(
nil
).
distinct
.
pluck
(
:source_branch
)
target_names
=
project
.
merge_requests
.
opened
.
reorder
(
nil
).
distinct
.
pluck
(
:target_branch
)
(
source_names
+
target_names
).
uniq
end
# rubocop: enable CodeReuse/ActiveRecord
...
...
app/services/labels/transfer_service.rb
View file @
db80db79
...
...
@@ -40,7 +40,7 @@ module Labels
group_labels_applied_to_merge_requests
])
.
reorder
(
nil
)
.
uniq
.
distinct
end
# rubocop: enable CodeReuse/ActiveRecord
...
...
changelogs/unreleased/rails5-deprecated-uniq.yml
0 → 100644
View file @
db80db79
---
title
:
Replace deprecated uniq on a Relation with distinct
merge_request
:
22625
author
:
Jasper Maes
type
:
other
lib/gitlab/contributions_calendar.rb
View file @
db80db79
...
...
@@ -73,7 +73,7 @@ module Gitlab
# re-running the contributed projects query in each union is expensive, so
# use IN(project_ids...) instead. It's the intersection of two users so
# the list will be (relatively) short
@contributed_project_ids
||=
projects
.
uniq
.
pluck
(
:id
)
@contributed_project_ids
||=
projects
.
distinct
.
pluck
(
:id
)
authed_projects
=
Project
.
where
(
id:
@contributed_project_ids
)
.
with_feature_available_for_user
(
feature
,
current_user
)
.
reorder
(
nil
)
...
...
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