Skip to content
Snippets Groups Projects

Commit statuses api add filter on pipeline_id and sort

Merged guillaume micouin requested to merge gmicouin/gitlab:dev/gmic/status_pipeline_id into master
@@ -46,7 +46,6 @@ class CommitStatuses < ::API::Base
optional :sort,
type: String,
values: ALLOWED_SORT_DIRECTIONS,
default: DEFAULT_SORT_DIRECTION,
desc: 'Return commit statuses sorted in `asc` or `desc` order. Default is `asc`',
documentation: { default: DEFAULT_SORT_DIRECTION }
use :pagination
@@ -58,16 +57,15 @@ class CommitStatuses < ::API::Base
not_found!('Commit') unless user_project.commit(params[:sha])
pipelines = user_project.ci_pipelines.where(sha: params[:sha])
pipelines = pipelines.where(id: params[:pipeline_id]) if params[:pipeline_id].present?
statuses = ::CommitStatus.where(pipeline: pipelines)
statuses = statuses.latest unless to_boolean(params[:all])
statuses = statuses.where(ref: params[:ref]) if params[:ref].present?
statuses = statuses.where(stage: params[:stage]) if params[:stage].present?
statuses = statuses.where(name: params[:name]) if params[:name].present?
statuses = statuses.where(pipeline_id: params[:pipeline_id]) if params[:pipeline_id].present?
statuses = order_statuses(statuses)
present paginate(statuses), with: Entities::CommitStatus
end
# rubocop: enable CodeReuse/ActiveRecord
desc 'Post status to a commit' do
Loading