move start all to query
This commit is contained in:
parent
be01b36f05
commit
0d1dbaadd7
|
@ -5,6 +5,19 @@ module Travis::API::V3
|
|||
Models::Cron.where(:branch_id => repository.branches)
|
||||
end
|
||||
|
||||
def start_all()
|
||||
started = []
|
||||
|
||||
Models::Cron.all.each do |cron|
|
||||
if cron.next_enqueuing <= Time.now
|
||||
start(cron.branch)
|
||||
started.push cron
|
||||
end
|
||||
end
|
||||
|
||||
started
|
||||
end
|
||||
|
||||
def start(branch)
|
||||
raise ServerError, 'repository does not have a github_id'.freeze unless branch.repository.github_id
|
||||
|
||||
|
|
|
@ -2,16 +2,7 @@ module Travis::API::V3
|
|||
class Services::Crons::Start < Service
|
||||
|
||||
def run!
|
||||
started = []
|
||||
|
||||
Models::Cron.all.each do |cron|
|
||||
if cron.next_enqueuing <= Time.now
|
||||
query.start(cron.branch)
|
||||
started.push cron
|
||||
end
|
||||
end
|
||||
|
||||
started
|
||||
query.start_all()
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user