Commit 17b9128b authored by Shinya Maeda's avatar Shinya Maeda

includes last_pipeline

parent df6040bb
...@@ -690,9 +690,7 @@ module API ...@@ -690,9 +690,7 @@ module API
expose :id expose :id
expose :description, :ref, :cron, :cron_timezone, :next_run_at, :active expose :description, :ref, :cron, :cron_timezone, :next_run_at, :active
expose :created_at, :updated_at, :deleted_at expose :created_at, :updated_at, :deleted_at
expose :last_pipeline, using: Entities::Pipeline do |pipeline_schedule| expose :last_pipeline, using: Entities::Pipeline
pipeline_schedule.pipelines&.last
end
expose :owner, using: Entities::UserBasic expose :owner, using: Entities::UserBasic
end end
......
...@@ -17,7 +17,7 @@ module API ...@@ -17,7 +17,7 @@ module API
get ':id/pipeline_schedules' do get ':id/pipeline_schedules' do
authorize! :read_pipeline_schedule, user_project authorize! :read_pipeline_schedule, user_project
pipeline_schedules = user_project.pipeline_schedules.preload(:pipelines) pipeline_schedules = user_project.pipeline_schedules.includes(last_pipeline: {statuses: :latest})
present paginate(pipeline_schedules), with: Entities::PipelineSchedule present paginate(pipeline_schedules), with: Entities::PipelineSchedule
end end
......
...@@ -31,6 +31,9 @@ describe API::PipelineSchedules do ...@@ -31,6 +31,9 @@ describe API::PipelineSchedules do
end.count end.count
create_list(:ci_pipeline_schedule, 10, project: project, owner: developer) create_list(:ci_pipeline_schedule, 10, project: project, owner: developer)
.each do |pipeline_schedule|
pipeline_schedule.pipelines << build(:ci_pipeline, project: project)
end
expect do expect do
get api("/projects/#{project.id}/pipeline_schedules", developer) get api("/projects/#{project.id}/pipeline_schedules", developer)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment