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)
|
Models::Cron.where(:branch_id => repository.branches)
|
||||||
end
|
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)
|
def start(branch)
|
||||||
raise ServerError, 'repository does not have a github_id'.freeze unless branch.repository.github_id
|
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
|
class Services::Crons::Start < Service
|
||||||
|
|
||||||
def run!
|
def run!
|
||||||
started = []
|
query.start_all()
|
||||||
|
|
||||||
Models::Cron.all.each do |cron|
|
|
||||||
if cron.next_enqueuing <= Time.now
|
|
||||||
query.start(cron.branch)
|
|
||||||
started.push cron
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
started
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user