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
922e6cf0
Commit
922e6cf0
authored
Dec 15, 2016
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactored code a little based on feedback
parent
a05649b1
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
12 additions
and
9 deletions
+12
-9
doc/api/users.md
doc/api/users.md
+1
-1
lib/api/issues.rb
lib/api/issues.rb
+1
-1
lib/api/users.rb
lib/api/users.rb
+1
-1
lib/gitlab/pagination_delegate.rb
lib/gitlab/pagination_delegate.rb
+3
-3
lib/gitlab/user_activities/activity.rb
lib/gitlab/user_activities/activity.rb
+1
-1
lib/gitlab/user_activities/activity_set.rb
lib/gitlab/user_activities/activity_set.rb
+5
-2
No files found.
doc/api/users.md
View file @
922e6cf0
...
@@ -865,7 +865,7 @@ Parameters:
...
@@ -865,7 +865,7 @@ Parameters:
| Attribute | Type | Required | Description |
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| --------- | ---- | -------- | ----------- |
|
`from`
| string | no | Date
time
string in the format YEAR-MONTH-DAY, e.g.
`2016-03-11`
. Defaults to 6 months ago. |
|
`from`
| string | no | Date string in the format YEAR-MONTH-DAY, e.g.
`2016-03-11`
. Defaults to 6 months ago. |
```
bash
```
bash
curl
--header
"PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK"
https://gitlab.example.com/api/v3/user/activities
curl
--header
"PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK"
https://gitlab.example.com/api/v3/user/activities
...
...
lib/api/issues.rb
View file @
922e6cf0
...
@@ -35,7 +35,7 @@ module API
...
@@ -35,7 +35,7 @@ module API
optional
:assignee_id
,
type:
Integer
,
desc:
'The ID of a user to assign issue'
optional
:assignee_id
,
type:
Integer
,
desc:
'The ID of a user to assign issue'
optional
:milestone_id
,
type:
Integer
,
desc:
'The ID of a milestone to assign issue'
optional
:milestone_id
,
type:
Integer
,
desc:
'The ID of a milestone to assign issue'
optional
:labels
,
type:
String
,
desc:
'Comma-separated list of label names'
optional
:labels
,
type:
String
,
desc:
'Comma-separated list of label names'
optional
:due_date
,
type:
String
,
desc:
'Date
time
string in the format YEAR-MONTH-DAY'
optional
:due_date
,
type:
String
,
desc:
'Date string in the format YEAR-MONTH-DAY'
optional
:confidential
,
type:
Boolean
,
desc:
'Boolean parameter if the issue should be confidential'
optional
:confidential
,
type:
Boolean
,
desc:
'Boolean parameter if the issue should be confidential'
optional
:state_event
,
type:
String
,
values:
%w[open close]
,
optional
:state_event
,
type:
String
,
values:
%w[open close]
,
desc:
'State of the issue'
desc:
'State of the issue'
...
...
lib/api/users.rb
View file @
922e6cf0
...
@@ -459,7 +459,7 @@ module API
...
@@ -459,7 +459,7 @@ module API
desc
'Get a list of user activities'
desc
'Get a list of user activities'
params
do
params
do
optional
:from
,
type:
String
,
desc:
'Date
time
string in the format YEAR-MONTH-DAY'
optional
:from
,
type:
String
,
desc:
'Date string in the format YEAR-MONTH-DAY'
use
:pagination
use
:pagination
end
end
get
":activities"
do
get
":activities"
do
...
...
lib/gitlab/pagination_delegate.rb
View file @
922e6cf0
...
@@ -8,8 +8,8 @@ module Gitlab
...
@@ -8,8 +8,8 @@ module Gitlab
@options
=
{
default_per_page:
DEFAULT_PER_PAGE
,
@options
=
{
default_per_page:
DEFAULT_PER_PAGE
,
max_per_page:
MAX_PER_PAGE
}.
merge
(
options
)
max_per_page:
MAX_PER_PAGE
}.
merge
(
options
)
@page
=
sanitize_page
(
page
)
@per_page
=
sanitize_per_page
(
per_page
)
@per_page
=
sanitize_per_page
(
per_page
)
@page
=
sanitize_page
(
page
)
end
end
def
total_count
def
total_count
...
@@ -53,13 +53,13 @@ module Gitlab
...
@@ -53,13 +53,13 @@ module Gitlab
def
sanitize_per_page
(
per_page
)
def
sanitize_per_page
(
per_page
)
return
@options
[
:default_per_page
]
unless
per_page
&&
per_page
>
0
return
@options
[
:default_per_page
]
unless
per_page
&&
per_page
>
0
per_page
>
@options
[
:max_per_page
]
?
@options
[
:max_per_page
]
:
per_page
[
@options
[
:max_per_page
],
per_page
].
min
end
end
def
sanitize_page
(
page
)
def
sanitize_page
(
page
)
return
1
unless
page
&&
page
>
1
return
1
unless
page
&&
page
>
1
page
>
total_count
?
total_count
:
page
[
total_pages
,
page
].
min
end
end
end
end
end
end
lib/gitlab/user_activities/activity.rb
View file @
922e6cf0
...
@@ -9,7 +9,7 @@ module Gitlab
...
@@ -9,7 +9,7 @@ module Gitlab
end
end
def
last_activity_at
def
last_activity_at
@lat_activity_at
||=
Time
.
at
(
@time
).
to_s
(
:db
)
@la
s
t_activity_at
||=
Time
.
at
(
@time
).
to_s
(
:db
)
end
end
end
end
end
end
...
...
lib/gitlab/user_activities/activity_set.rb
View file @
922e6cf0
...
@@ -4,7 +4,6 @@ module Gitlab
...
@@ -4,7 +4,6 @@ module Gitlab
include
Gitlab
::
PaginationUtil
include
Gitlab
::
PaginationUtil
KEY
=
'user/activities'
KEY
=
'user/activities'
DEFAULT_FROM
=
6
.
months
.
ago
.
to_i
def
self
.
record
(
user
)
def
self
.
record
(
user
)
Gitlab
::
Redis
.
with
do
|
redis
|
Gitlab
::
Redis
.
with
do
|
redis
|
...
@@ -28,7 +27,7 @@ module Gitlab
...
@@ -28,7 +27,7 @@ module Gitlab
def
sanitize_date
(
date
)
def
sanitize_date
(
date
)
Time
.
strptime
(
date
,
"%Y-%m-%d"
).
to_i
Time
.
strptime
(
date
,
"%Y-%m-%d"
).
to_i
rescue
TypeError
,
ArgumentError
rescue
TypeError
,
ArgumentError
DEFAULT_FROM
default_from
end
end
def
pagination_delegate
def
pagination_delegate
...
@@ -52,6 +51,10 @@ module Gitlab
...
@@ -52,6 +51,10 @@ module Gitlab
def
limit
def
limit
[
pagination_delegate
.
offset
,
pagination_delegate
.
limit_value
]
[
pagination_delegate
.
offset
,
pagination_delegate
.
limit_value
]
end
end
def
default_from
6
.
months
.
ago
.
to_i
end
end
end
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