diff options
author | Stan Hu <stanhu@gmail.com> | 2019-08-08 04:40:55 +0000 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2019-08-08 04:40:55 +0000 |
commit | 3ad34c3a243cda19e73fbda0c9682e0a1c16c10a (patch) | |
tree | 38a419d054a0c999449d7837a311e28364e0cc42 /lib | |
parent | 4985f6e26d758e7d5e43c3525a4afe4a9459ce8e (diff) | |
parent | d4078b535c9854695e770cdfb5e0f4846a8cf64a (diff) | |
download | gitlab-ce-3ad34c3a243cda19e73fbda0c9682e0a1c16c10a.tar.gz |
Merge branch '20137-starrers' into 'master'
Add possibilty to view starrers ("stargazers") of a repository & any user's starred repositories
Closes #20137
See merge request gitlab-org/gitlab-ce!24690
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/entities.rb | 5 | ||||
-rw-r--r-- | lib/api/projects.rb | 29 |
2 files changed, 34 insertions, 0 deletions
diff --git a/lib/api/entities.rb b/lib/api/entities.rb index 2f5ce3d4003..643b53f5e63 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -77,6 +77,11 @@ module API expose :last_activity_on, as: :last_activity_at # Back-compat end + class UserStarsProject < Grape::Entity + expose :starred_since + expose :user, using: Entities::UserBasic + end + class Identity < Grape::Entity expose :provider, :extern_uid end diff --git a/lib/api/projects.rb b/lib/api/projects.rb index 0923d31f5ff..996205d4b7b 100644 --- a/lib/api/projects.rb +++ b/lib/api/projects.rb @@ -115,6 +115,22 @@ module API present_projects load_projects end + + desc 'Get projects starred by a user' do + success Entities::BasicProjectDetails + end + params do + requires :user_id, type: String, desc: 'The ID or username of the user' + use :collection_params + use :statistics_params + end + get ":user_id/starred_projects" do + user = find_user(params[:user_id]) + not_found!('User') unless user + + starred_projects = StarredProjectsFinder.new(user, params: project_finder_params, current_user: current_user).execute + present_projects starred_projects + end end resource :projects do @@ -358,6 +374,19 @@ module API end end + desc 'Get the users who starred a project' do + success Entities::UserBasic + end + params do + optional :search, type: String, desc: 'Return list of users matching the search criteria' + use :pagination + end + get ':id/starrers' do + starrers = UsersStarProjectsFinder.new(user_project, params, current_user: current_user).execute + + present paginate(starrers), with: Entities::UserStarsProject + end + desc 'Get languages in project repository' get ':id/languages' do ::Projects::RepositoryLanguagesService |