Commit f968729a authored by Alex Pooley's avatar Alex Pooley

Remove duplicate where condition

Changelog: performance
parent 81a67d1d
...@@ -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')) }
......
...@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment