summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/models/ci/pipeline_schedule.rb4
-rw-r--r--lib/api/entities.rb4
2 files changed, 3 insertions, 5 deletions
diff --git a/app/models/ci/pipeline_schedule.rb b/app/models/ci/pipeline_schedule.rb
index adac895ab7d..45d8cd34359 100644
--- a/app/models/ci/pipeline_schedule.rb
+++ b/app/models/ci/pipeline_schedule.rb
@@ -44,10 +44,6 @@ module Ci
self.next_run_at = Gitlab::Ci::CronParser.new(cron, cron_timezone).next_time_from(Time.now)
end
- def last_pipeline
- self.pipelines&.last
- end
-
def schedule_next_run!
save! # with set_next_run_at
rescue ActiveRecord::RecordInvalid
diff --git a/lib/api/entities.rb b/lib/api/entities.rb
index b2bc0a17142..93f28e39f82 100644
--- a/lib/api/entities.rb
+++ b/lib/api/entities.rb
@@ -690,7 +690,9 @@ module API
expose :id
expose :description, :ref, :cron, :cron_timezone, :next_run_at, :active
expose :created_at, :updated_at, :deleted_at
- expose :last_pipeline, using: Entities::Pipeline
+ expose :last_pipeline, using: Entities::Pipeline do |pipeline_schedule|
+ pipeline_schedule.pipelines&.last
+ end
expose :owner, using: Entities::UserBasic
end