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
2f808329
Commit
2f808329
authored
Dec 12, 2016
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added user activities redis logic
parent
e5686a29
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
3 deletions
+35
-3
app/models/user.rb
app/models/user.rb
+1
-3
lib/gitlab/user_activities.rb
lib/gitlab/user_activities.rb
+34
-0
No files found.
app/models/user.rb
View file @
2f808329
...
...
@@ -948,9 +948,7 @@ class User < ActiveRecord::Base
end
def
record_activity
Gitlab
::
Redis
.
with
do
|
redis
|
redis
.
zadd
(
'user/activities'
,
Time
.
now
.
to_i
,
self
.
username
)
end
Gitlab
::
UserActivities
.
record
(
self
)
end
private
...
...
lib/gitlab/user_activities.rb
0 → 100644
View file @
2f808329
module
Gitlab
class
UserActivities
KEY
=
'user/activities'
DEFAULT_PAGE_SIZE
=
50
def
self
.
record
(
user
)
Gitlab
::
Redis
.
with
do
|
redis
|
redis
.
zadd
(
KEY
,
Time
.
now
.
to_i
,
user
.
username
)
end
end
def
self
.
query
(
*
args
)
new
(
*
args
).
query
end
def
initialize
(
from:
6
.
months
.
ago
,
page:
0
,
per_page:
DEFAULT_PAGE_SIZE
)
@from
=
from
@page
=
page
@per_page
=
per_page
end
def
query
Gitlab
::
Redis
.
with
do
|
redis
|
redis
.
zrangebyscore
(
KEY
,
@from
.
to_i
,
Time
.
now
.
to_i
,
with_scores:
true
,
limit:
[
offset
,
@per_page
])
end
end
private
def
offset
@page
*
@per_page
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