From 5b20df0a9276bc1250dc8b307adb161b24d9c255 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Fri, 25 Jan 2019 18:34:45 +0100 Subject: Add projects/:id/starrers API endpoint for users who starred a repository --- lib/api/projects.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'lib/api/projects.rb') diff --git a/lib/api/projects.rb b/lib/api/projects.rb index 0923d31f5ff..ed9f5a9039e 100644 --- a/lib/api/projects.rb +++ b/lib/api/projects.rb @@ -358,6 +358,18 @@ module API end end + desc 'List users who starred this project' do + success Entities::UserBasic + end + params do + use :collection_params + end + get ':id/starrers' do + users = DeclarativePolicy.subject_scope { user_project.starrers } + + present users, with: Entities::UserBasic + end + desc 'Get languages in project repository' get ':id/languages' do ::Projects::RepositoryLanguagesService -- cgit v1.2.1 From d03a4c9a07c1a1eebbb209514957abd3278bd602 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Sun, 27 Jan 2019 12:45:43 +0100 Subject: Add users/:user_id/starred_projects API endpoint for projects starred by a user --- lib/api/projects.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'lib/api/projects.rb') diff --git a/lib/api/projects.rb b/lib/api/projects.rb index ed9f5a9039e..e24c5765de5 100644 --- a/lib/api/projects.rb +++ b/lib/api/projects.rb @@ -115,6 +115,22 @@ module API present_projects load_projects end + + desc 'Get a user\'s starred projects' 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).execute(current_user) + present_projects starred_projects + end end resource :projects do -- cgit v1.2.1 From e7c34c37c83d877a887173d833ba4103772d1566 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Mon, 28 Jan 2019 20:01:18 +0100 Subject: Add documentation and changelog for !24690 --- lib/api/projects.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'lib/api/projects.rb') diff --git a/lib/api/projects.rb b/lib/api/projects.rb index e24c5765de5..dc9959b619f 100644 --- a/lib/api/projects.rb +++ b/lib/api/projects.rb @@ -116,7 +116,7 @@ module API present_projects load_projects end - desc 'Get a user\'s starred projects' do + desc 'Get projects starred by a user' do success Entities::BasicProjectDetails end params do @@ -374,16 +374,18 @@ module API end end - desc 'List users who starred this project' do + desc 'Get the users who starred a project' do success Entities::UserBasic end params do - use :collection_params + optional :search, type: String, desc: 'Return list of users matching the search criteria' + use :pagination end get ':id/starrers' do users = DeclarativePolicy.subject_scope { user_project.starrers } + users = users.search(params[:search]) if params[:search].present? - present users, with: Entities::UserBasic + present paginate(users), with: Entities::UserBasic end desc 'Get languages in project repository' -- cgit v1.2.1 From 1ec8c0e837ff4ba42adbc7cc1e9a15a04f2afd7e Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Mon, 28 Jan 2019 20:57:56 +0100 Subject: Fix API endpoint for starred projects of a user; add info about starred projects on profile to documentation --- lib/api/projects.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/api/projects.rb') diff --git a/lib/api/projects.rb b/lib/api/projects.rb index dc9959b619f..f8f0ff48be0 100644 --- a/lib/api/projects.rb +++ b/lib/api/projects.rb @@ -128,7 +128,7 @@ module API user = find_user(params[:user_id]) not_found!('User') unless user - starred_projects = StarredProjectsFinder.new(user).execute(current_user) + starred_projects = StarredProjectsFinder.new(user, current_user: current_user).execute present_projects starred_projects end end -- cgit v1.2.1 From e8bdcdf0f89d88463f6fb8a67e85f315e6a9097d Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Sat, 2 Feb 2019 20:48:27 +0100 Subject: Expose time since starring on project/:id/starrers API endpoint; exclude private profiles here as well --- lib/api/projects.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'lib/api/projects.rb') diff --git a/lib/api/projects.rb b/lib/api/projects.rb index f8f0ff48be0..6d221200372 100644 --- a/lib/api/projects.rb +++ b/lib/api/projects.rb @@ -128,7 +128,7 @@ module API user = find_user(params[:user_id]) not_found!('User') unless user - starred_projects = StarredProjectsFinder.new(user, current_user: current_user).execute + starred_projects = StarredProjectsFinder.new(user, params: project_finder_params, current_user: current_user).execute present_projects starred_projects end end @@ -382,10 +382,9 @@ module API use :pagination end get ':id/starrers' do - users = DeclarativePolicy.subject_scope { user_project.starrers } - users = users.search(params[:search]) if params[:search].present? + starrers = UsersStarProjectsFinder.new(params, user_project, current_user: current_user).execute - present paginate(users), with: Entities::UserBasic + present paginate(starrers), with: Entities::UserStarsProject end desc 'Get languages in project repository' -- cgit v1.2.1 From 99bb207ef14d12fe59e23fd70e219ed5e166470b Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Sat, 2 Feb 2019 20:53:21 +0100 Subject: Fix tests --- lib/api/projects.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/api/projects.rb') diff --git a/lib/api/projects.rb b/lib/api/projects.rb index 6d221200372..996205d4b7b 100644 --- a/lib/api/projects.rb +++ b/lib/api/projects.rb @@ -382,7 +382,7 @@ module API use :pagination end get ':id/starrers' do - starrers = UsersStarProjectsFinder.new(params, user_project, current_user: current_user).execute + starrers = UsersStarProjectsFinder.new(user_project, params, current_user: current_user).execute present paginate(starrers), with: Entities::UserStarsProject end -- cgit v1.2.1