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
f968729a
Commit
f968729a
authored
Jun 16, 2021
by
Alex Pooley
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove duplicate where condition
Changelog: performance
parent
81a67d1d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
1 deletion
+15
-1
app/models/member.rb
app/models/member.rb
+1
-1
spec/models/member_spec.rb
spec/models/member_spec.rb
+14
-0
No files found.
app/models/member.rb
View file @
f968729a
...
@@ -156,7 +156,7 @@ class Member < ApplicationRecord
...
@@ -156,7 +156,7 @@ class Member < ApplicationRecord
distinct_members
=
select
(
'DISTINCT ON (user_id, invite_email) *'
)
distinct_members
=
select
(
'DISTINCT ON (user_id, invite_email) *'
)
.
order
(
'user_id, invite_email, access_level DESC, expires_at DESC, created_at ASC'
)
.
order
(
'user_id, invite_email, access_level DESC, expires_at DESC, created_at ASC'
)
from
(
distinct_members
,
:members
)
unscoped
.
from
(
distinct_members
,
:members
)
end
end
scope
:order_name_asc
,
->
{
left_join_users
.
reorder
(
Gitlab
::
Database
.
nulls_last_order
(
'users.name'
,
'ASC'
))
}
scope
:order_name_asc
,
->
{
left_join_users
.
reorder
(
Gitlab
::
Database
.
nulls_last_order
(
'users.name'
,
'ASC'
))
}
...
...
spec/models/member_spec.rb
View file @
f968729a
...
@@ -476,6 +476,20 @@ RSpec.describe Member do
...
@@ -476,6 +476,20 @@ RSpec.describe Member do
it
{
is_expected
.
to
include
@blocked_maintainer
}
it
{
is_expected
.
to
include
@blocked_maintainer
}
it
{
is_expected
.
to
include
@blocked_developer
}
it
{
is_expected
.
to
include
@blocked_developer
}
it
{
is_expected
.
to
include
@member_with_minimal_access
}
it
{
is_expected
.
to
include
@member_with_minimal_access
}
context
'with where conditions'
do
let_it_be
(
:example_member
)
{
create
(
:group_member
,
invite_email:
'user@example.com'
)
}
subject
do
described_class
.
default_scoped
.
where
(
invite_email:
'user@example.com'
)
.
distinct_on_user_with_max_access_level
.
to_a
end
it
{
is_expected
.
to
eq
[
example_member
]
}
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