fix job enqueueing
This commit is contained in:
parent
4704992a18
commit
2d2e7aa528
|
@ -4,21 +4,28 @@ module Travis::API::V3
|
||||||
belongs_to :branch
|
belongs_to :branch
|
||||||
|
|
||||||
def self.start_all
|
def self.start_all
|
||||||
|
started = []
|
||||||
|
|
||||||
self.all.each do |cron|
|
self.all.each do |cron|
|
||||||
cron.start if cron.next_build_time <= Time.now
|
if cron.next_build_time <= Time.now
|
||||||
|
cron.start
|
||||||
|
started.push cron
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
started
|
||||||
|
end
|
||||||
|
|
||||||
def start
|
def start
|
||||||
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
|
||||||
|
|
||||||
payload = {
|
payload = {
|
||||||
repository: { id: branch.repository.github_id, owner_name: branch.repository.owner_name, name: branch.repository.name },
|
repository: { id: branch.repository.github_id, owner_name: branch.repository.owner_name, name: branch.repository.name },
|
||||||
user: { id: user.id },
|
branch: branch.name
|
||||||
branch: branch
|
|
||||||
}
|
}
|
||||||
|
|
||||||
perform_async(:build_request, type: 'cron'.freeze, payload: JSON.dump(payload))
|
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
|
payload
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user