diff options
-rw-r--r-- | lib/api/access_requests.rb | 5 | ||||
-rw-r--r-- | lib/api/entities.rb | 4 | ||||
-rw-r--r-- | lib/api/members.rb | 6 |
3 files changed, 7 insertions, 8 deletions
diff --git a/lib/api/access_requests.rb b/lib/api/access_requests.rb index 9c41d8aaa3e..d02b469dac8 100644 --- a/lib/api/access_requests.rb +++ b/lib/api/access_requests.rb @@ -18,10 +18,9 @@ module API source = find_source(source_type, params[:id]) authorize_admin_source!(source_type, source) - access_requesters = source.requesters - users = Kaminari.paginate_array(access_requesters.map(&:user)) + access_requesters = paginate(source.requesters.includes(:user)) - present paginate(users), with: Entities::AccessRequester, source: source + present access_requesters.map(&:user), with: Entities::AccessRequester, access_requesters: access_requesters end # Request access to the group/project diff --git a/lib/api/entities.rb b/lib/api/entities.rb index c5ff4557b4a..ae74d14a4bb 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -93,14 +93,14 @@ module API class Member < UserBasic expose :access_level do |user, options| - member = options[:member] || options[:source].members.find_by(user_id: user.id) + member = options[:member] || options[:members].find { |m| m.user_id == user.id } member.access_level end end class AccessRequester < UserBasic expose :requested_at do |user, options| - access_requester = options[:access_requester] || options[:source].requesters.find_by(user_id: user.id) + access_requester = options[:access_requester] || options[:access_requesters].find { |m| m.user_id == user.id } access_requester.requested_at end end diff --git a/lib/api/members.rb b/lib/api/members.rb index ccb7618360d..2fae83f60b2 100644 --- a/lib/api/members.rb +++ b/lib/api/members.rb @@ -18,11 +18,11 @@ module API get ":id/members" do source = find_source(source_type, params[:id]) - members = source.members + members = source.members.includes(:user) members = members.joins(:user).merge(User.search(params[:query])) if params[:query] - users = Kaminari.paginate_array(members.map(&:user)) + members = paginate(members) - present paginate(users), with: Entities::Member, source: source + present members.map(&:user), with: Entities::Member, members: members end # Get a group/project member |