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
37dfe202
Commit
37dfe202
authored
Jun 29, 2018
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve performance of User.without_projects scope
parent
d555a8a4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
1 deletion
+6
-1
app/models/user.rb
app/models/user.rb
+1
-1
changelogs/unreleased/dm-user-without-projects-performance.yml
...elogs/unreleased/dm-user-without-projects-performance.yml
+5
-0
No files found.
app/models/user.rb
View file @
37dfe202
...
...
@@ -248,7 +248,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
:subscribed_for_admin_email
,
->
{
where
(
admin_email_unsubscribed_at:
nil
)
}
scope
:ldap
,
->
{
joins
(
:identities
).
where
(
'identities.provider LIKE ?'
,
'ldap%'
)
}
scope
:with_provider
,
->
(
provider
)
do
...
...
changelogs/unreleased/dm-user-without-projects-performance.yml
0 → 100644
View file @
37dfe202
---
title
:
Improve performance of listing users without projects
merge_request
:
author
:
type
:
performance
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