Improve performance of User.without_projects scope
This commit is contained in:
parent
50a213112e
commit
29e2e1888b
2 changed files with 6 additions and 1 deletions
|
@ -244,7 +244,7 @@ class User < ActiveRecord::Base
|
|||
scope :blocked, -> { with_states(:blocked, :ldap_blocked) }
|
||||
scope :external, -> { where(external: true) }
|
||||
scope :active, -> { with_state(:active).non_internal }
|
||||
scope :without_projects, -> { where('id NOT IN (SELECT DISTINCT(user_id) FROM members WHERE user_id IS NOT NULL AND requested_at IS NULL)') }
|
||||
scope :without_projects, -> { joins('LEFT JOIN project_authorizations ON users.id = project_authorizations.user_id').where(project_authorizations: { user_id: nil }) }
|
||||
scope :todo_authors, ->(user_id, state) { where(id: Todo.where(user_id: user_id, state: state).select(:author_id)) }
|
||||
scope :order_recent_sign_in, -> { reorder(Gitlab::Database.nulls_last_order('current_sign_in_at', 'DESC')) }
|
||||
scope :order_oldest_sign_in, -> { reorder(Gitlab::Database.nulls_last_order('current_sign_in_at', 'ASC')) }
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: Improve performance of listing users without projects
|
||||
merge_request:
|
||||
author:
|
||||
type: performance
|
Loading…
Reference in a new issue