diff options
| author | Jacopo <beschi.jacopo@gmail.com> | 2017-11-18 15:06:55 +0100 | 
|---|---|---|
| committer | Jacopo <beschi.jacopo@gmail.com> | 2017-12-13 18:02:20 +0100 | 
| commit | 55f322085d0507640366b7a774fe7819771ff54b (patch) | |
| tree | 30fcb5e3f952fa007445342cbd67802a7f0958e3 /lib | |
| parent | 6930fa3102f0ba197e969f9996e86bf11346470c (diff) | |
| download | gitlab-ce-55f322085d0507640366b7a774fe7819771ff54b.tar.gz | |
Adds ordering to projects contributors in API
Allows ordering in GET api/v4/projects/:project_id/repository/contributors
through `order_by` and `sort` params.
The available `order_by` options are: name|email|commits.
The available `sort` options are: asc|desc.
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/api/repositories.rb | 4 | 
1 files changed, 3 insertions, 1 deletions
| diff --git a/lib/api/repositories.rb b/lib/api/repositories.rb index 7887b886c03..4f36bbd760f 100644 --- a/lib/api/repositories.rb +++ b/lib/api/repositories.rb @@ -110,10 +110,12 @@ module API        end        params do          use :pagination +        optional :order_by, type: String, values: %w[email name commits], default: nil, desc: 'Return contributors ordered by `name` or `email` or `commits`' +        optional :sort, type: String, values: %w[asc desc], default: nil, desc: 'Sort by asc (ascending) or desc (descending)'        end        get ':id/repository/contributors' do          begin -          contributors = ::Kaminari.paginate_array(user_project.repository.contributors) +          contributors = ::Kaminari.paginate_array(user_project.repository.contributors(order_by: params[:order_by], sort: params[:sort]))            present paginate(contributors), with: Entities::Contributor          rescue            not_found! | 
