diff options
author | Robert Speicher <robert@gitlab.com> | 2016-10-12 11:33:19 +0000 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2016-10-12 11:33:19 +0000 |
commit | 7c07c07d7a2b93ab81964b9cd28736652da1370a (patch) | |
tree | 41734446a104fa184195e7b71601a762a22adbb9 /lib/api | |
parent | c004bb3e74b6a60a4b6ede93d0ea8a898e56c41b (diff) | |
parent | c7865786572a3a2e12ed67a3f8121c0be8c4ba38 (diff) | |
download | gitlab-ce-7c07c07d7a2b93ab81964b9cd28736652da1370a.tar.gz |
Merge branch 'user-events-api' into 'master'
API: New /users/:id/events endpoint
## What does this MR do?
If add a new `/users/:id/events` endpoint to retrieve a user's contribution events. The events returned are filtered so that only the events for projects that the current user can see are returned (similarly to what we do at the controller level).
## Why was this MR needed?
Because it's a nice feature to calculate leaderboards, for instance for #17815.
## What are the relevant issue numbers?
Closes #20866.
See merge request !6771
Diffstat (limited to 'lib/api')
-rw-r--r-- | lib/api/users.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/api/users.rb b/lib/api/users.rb index 18c4cad09ae..e868f628404 100644 --- a/lib/api/users.rb +++ b/lib/api/users.rb @@ -321,6 +321,26 @@ module API user.activate end end + + desc 'Get contribution events of a specified user' do + detail 'This feature was introduced in GitLab 8.13.' + success Entities::Event + end + params do + requires :id, type: String, desc: 'The user ID' + end + get ':id/events' do + user = User.find_by(id: declared(params).id) + not_found!('User') unless user + + events = user.recent_events. + merge(ProjectsFinder.new.execute(current_user)). + references(:project). + with_associations. + page(params[:page]) + + present paginate(events), with: Entities::Event + end end resource :user do |