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
Léo-Paul Géneau
gitlab-ce
Commits
cca13d1e
Commit
cca13d1e
authored
Aug 26, 2017
by
Poornima
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Using correct column for sorting users by Recent Sign-in
Removing last_sign_in_at in specs
parent
1214d8de
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
10 deletions
+20
-10
app/models/user.rb
app/models/user.rb
+2
-2
changelogs/unreleased/26468-fix-sort-by-recent-sign-in.yml
changelogs/unreleased/26468-fix-sort-by-recent-sign-in.yml
+4
-0
spec/models/user_spec.rb
spec/models/user_spec.rb
+14
-8
No files found.
app/models/user.rb
View file @
cca13d1e
...
@@ -230,8 +230,8 @@ class User < ActiveRecord::Base
...
@@ -230,8 +230,8 @@ class User < ActiveRecord::Base
scope
:active
,
->
{
with_state
(
:active
).
non_internal
}
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
,
->
{
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
))
}
scope
:order_recent_sign_in
,
->
{
reorder
(
Gitlab
::
Database
.
nulls_last_order
(
'
las
t_sign_in_at'
,
'DESC'
))
}
scope
:order_recent_sign_in
,
->
{
reorder
(
Gitlab
::
Database
.
nulls_last_order
(
'
curren
t_sign_in_at'
,
'DESC'
))
}
scope
:order_oldest_sign_in
,
->
{
reorder
(
Gitlab
::
Database
.
nulls_last_order
(
'
las
t_sign_in_at'
,
'ASC'
))
}
scope
:order_oldest_sign_in
,
->
{
reorder
(
Gitlab
::
Database
.
nulls_last_order
(
'
curren
t_sign_in_at'
,
'ASC'
))
}
def
self
.
with_two_factor
def
self
.
with_two_factor
joins
(
"LEFT OUTER JOIN u2f_registrations AS u2f ON u2f.user_id = users.id"
)
joins
(
"LEFT OUTER JOIN u2f_registrations AS u2f ON u2f.user_id = users.id"
)
...
...
changelogs/unreleased/26468-fix-sort-by-recent-sign-in.yml
0 → 100644
View file @
cca13d1e
---
title
:
Fix Sort by Recent Sign-in in Admin Area
merge_request
:
13852
author
:
Poornima M
spec/models/user_spec.rb
View file @
cca13d1e
...
@@ -1433,28 +1433,34 @@ describe User do
...
@@ -1433,28 +1433,34 @@ describe User do
describe
'#sort'
do
describe
'#sort'
do
before
do
before
do
described_class
.
delete_all
described_class
.
delete_all
@user
=
create
:user
,
created_at:
Date
.
today
,
las
t_sign_in_at:
Date
.
today
,
name:
'Alpha'
@user
=
create
:user
,
created_at:
Date
.
today
,
curren
t_sign_in_at:
Date
.
today
,
name:
'Alpha'
@user1
=
create
:user
,
created_at:
Date
.
today
-
1
,
las
t_sign_in_at:
Date
.
today
-
1
,
name:
'Omega'
@user1
=
create
:user
,
created_at:
Date
.
today
-
1
,
curren
t_sign_in_at:
Date
.
today
-
1
,
name:
'Omega'
@user2
=
create
:user
,
created_at:
Date
.
today
-
2
,
last_sign_in_at:
nil
,
name:
'Beta'
@user2
=
create
:user
,
created_at:
Date
.
today
-
2
,
name:
'Beta'
end
end
context
'when sort by recent_sign_in'
do
context
'when sort by recent_sign_in'
do
it
'sorts users by the recent sign-in time'
do
let
(
:users
)
{
described_class
.
sort
(
'recent_sign_in'
)
}
expect
(
described_class
.
sort
(
'recent_sign_in'
).
first
).
to
eq
(
@user
)
it
'sorts users by recent sign-in time'
do
expect
(
users
.
first
).
to
eq
(
@user
)
expect
(
users
.
second
).
to
eq
(
@user1
)
end
end
it
'pushes users who never signed in to the end'
do
it
'pushes users who never signed in to the end'
do
expect
(
described_class
.
sort
(
'recent_sign_in'
)
.
third
).
to
eq
(
@user2
)
expect
(
users
.
third
).
to
eq
(
@user2
)
end
end
end
end
context
'when sort by oldest_sign_in'
do
context
'when sort by oldest_sign_in'
do
let
(
:users
)
{
described_class
.
sort
(
'oldest_sign_in'
)
}
it
'sorts users by the oldest sign-in time'
do
it
'sorts users by the oldest sign-in time'
do
expect
(
described_class
.
sort
(
'oldest_sign_in'
).
first
).
to
eq
(
@user1
)
expect
(
users
.
first
).
to
eq
(
@user1
)
expect
(
users
.
second
).
to
eq
(
@user
)
end
end
it
'pushes users who never signed in to the end'
do
it
'pushes users who never signed in to the end'
do
expect
(
described_class
.
sort
(
'oldest_sign_in'
)
.
third
).
to
eq
(
@user2
)
expect
(
users
.
third
).
to
eq
(
@user2
)
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