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
41901461
Commit
41901461
authored
Apr 19, 2017
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix active user count
parent
bbd83376
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
1 deletion
+17
-1
app/models/user.rb
app/models/user.rb
+1
-1
changelogs/unreleased/fix-user-count.yml
changelogs/unreleased/fix-user-count.yml
+4
-0
spec/models/user_spec.rb
spec/models/user_spec.rb
+12
-0
No files found.
app/models/user.rb
View file @
41901461
...
@@ -197,7 +197,7 @@ class User < ActiveRecord::Base
...
@@ -197,7 +197,7 @@ class User < ActiveRecord::Base
scope
:admins
,
->
{
where
(
admin:
true
)
}
scope
:admins
,
->
{
where
(
admin:
true
)
}
scope
:blocked
,
->
{
with_states
(
:blocked
,
:ldap_blocked
)
}
scope
:blocked
,
->
{
with_states
(
:blocked
,
:ldap_blocked
)
}
scope
:external
,
->
{
where
(
external:
true
)
}
scope
:external
,
->
{
where
(
external:
true
)
}
scope
:active
,
->
{
with_state
(
:active
)
}
scope
:active
,
->
{
with_state
(
:active
)
.
non_internal
}
scope
:not_in_project
,
->
(
project
)
{
project
.
users
.
present?
?
where
(
"id not in (:ids)"
,
ids:
project
.
users
.
map
(
&
:id
)
)
:
all
}
scope
:not_in_project
,
->
(
project
)
{
project
.
users
.
present?
?
where
(
"id not in (:ids)"
,
ids:
project
.
users
.
map
(
&
:id
)
)
:
all
}
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
,
->
{
where
(
'id NOT IN (SELECT DISTINCT(user_id) FROM members WHERE user_id IS NOT NULL AND requested_at IS NULL)'
)
}
scope
:todo_authors
,
->
(
user_id
,
state
)
{
where
(
id:
Todo
.
where
(
user_id:
user_id
,
state:
state
).
select
(
:author_id
))
}
scope
:todo_authors
,
->
(
user_id
,
state
)
{
where
(
id:
Todo
.
where
(
user_id:
user_id
,
state:
state
).
select
(
:author_id
))
}
...
...
changelogs/unreleased/fix-user-count.yml
0 → 100644
View file @
41901461
---
title
:
Fix active user count to ignore internal users
merge_request
:
author
:
spec/models/user_spec.rb
View file @
41901461
...
@@ -1631,4 +1631,16 @@ describe User, models: true do
...
@@ -1631,4 +1631,16 @@ describe User, models: true do
end
end
end
end
end
end
context
'.active'
do
before
do
User
.
ghost
create
(
:user
,
name:
'user'
,
state:
'active'
)
create
(
:user
,
name:
'user'
,
state:
'blocked'
)
end
it
'only counts active and non internal users'
do
expect
(
User
.
active
.
count
).
to
eq
(
1
)
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