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
Boxiang Sun
gitlab-ce
Commits
29e2e188
Commit
29e2e188
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
50a21311
Changes
2
Show 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 @
29e2e188
...
...
@@ -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'
))
}
...
...
changelogs/unreleased/dm-user-without-projects-performance.yml
0 → 100644
View file @
29e2e188
---
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