move start cronjob to services
This commit is contained in:
parent
05d2e4767e
commit
24b0af35e9
|
@ -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
|
||||
|
||||
|
|
18
lib/travis/api/v3/services/crons/start.rb
Normal file
18
lib/travis/api/v3/services/crons/start.rb
Normal 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
|
Loading…
Reference in New Issue
Block a user