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/entities.rb | 5 +++++ lib/api/projects.rb | 7 +++---- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'lib') 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 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