diff --git a/lib/travis/api/v3/models/cron.rb b/lib/travis/api/v3/models/cron.rb index ba792b6b..90f208c4 100644 --- a/lib/travis/api/v3/models/cron.rb +++ b/lib/travis/api/v3/models/cron.rb @@ -3,19 +3,6 @@ module Travis::API::V3 belongs_to :branch - def self.start_all - started = [] - - self.all.each do |cron| - if cron.next_build_time <= Time.now - cron.start - started.push cron - end - end - - started - end - def start raise ServerError, 'repository does not have a github_id'.freeze unless branch.repository.github_id diff --git a/lib/travis/api/v3/services/crons/start.rb b/lib/travis/api/v3/services/crons/start.rb new file mode 100644 index 00000000..2ee13131 --- /dev/null +++ b/lib/travis/api/v3/services/crons/start.rb @@ -0,0 +1,18 @@ +module Travis::API::V3 + class Services::Crons::Start < Service + + def run! + started = [] + + Models::Cron.all.each do |cron| + if cron.next_build_time <= Time.now + cron.start + started.push cron + end + end + + started + end + + end +end