move start cronjob to services

This commit is contained in:
Steffen Kötte 2016-01-28 13:16:53 +01:00
parent 05d2e4767e
commit 24b0af35e9
2 changed files with 18 additions and 13 deletions

View File

@ -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

View File

@ -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