move cron start to query
This commit is contained in:
parent
64478d50d1
commit
d75daab82f
|
@ -3,19 +3,6 @@ module Travis::API::V3
|
|||
|
||||
belongs_to :branch
|
||||
|
||||
def start
|
||||
raise ServerError, 'repository does not have a github_id'.freeze unless branch.repository.github_id
|
||||
|
||||
payload = {
|
||||
repository: { id: branch.repository.github_id, owner_name: branch.repository.owner_name, name: branch.repository.name },
|
||||
branch: branch.name
|
||||
}
|
||||
|
||||
class_name, queue = Query.sidekiq_queue(:build_request)
|
||||
::Sidekiq::Client.push('queue'.freeze => queue, 'class'.freeze => class_name, 'args'.freeze => [{type: 'cron'.freeze, payload: JSON.dump(payload)}])
|
||||
payload
|
||||
end
|
||||
|
||||
def next_enqueuing
|
||||
|
||||
if (disable_by_build) && (last_non_cron_build_date > last_planned_time)
|
||||
|
|
|
@ -4,5 +4,18 @@ module Travis::API::V3
|
|||
def find(branch)
|
||||
branch.cron
|
||||
end
|
||||
|
||||
def start(branch)
|
||||
raise ServerError, 'repository does not have a github_id'.freeze unless branch.repository.github_id
|
||||
|
||||
payload = {
|
||||
repository: { id: branch.repository.github_id, owner_name: branch.repository.owner_name, name: branch.repository.name },
|
||||
branch: branch.name
|
||||
}
|
||||
|
||||
class_name, queue = Query.sidekiq_queue(:build_request)
|
||||
::Sidekiq::Client.push('queue'.freeze => queue, 'class'.freeze => class_name, 'args'.freeze => [{type: 'cron'.freeze, payload: JSON.dump(payload)}])
|
||||
payload
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,7 +6,7 @@ module Travis::API::V3
|
|||
|
||||
Models::Cron.all.each do |cron|
|
||||
if cron.next_enqueuing <= Time.now
|
||||
cron.start
|
||||
query.start(cron.branch)
|
||||
started.push cron
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user