Add rake task for updating branch value on builds
This commit is contained in:
parent
a22ae8a745
commit
201e7a3176
21
lib/tasks/build_update_branch.rake
Normal file
21
lib/tasks/build_update_branch.rake
Normal file
|
@ -0,0 +1,21 @@
|
|||
namespace :build do
|
||||
namespace :migrate do
|
||||
task :branch do
|
||||
require 'travis'
|
||||
Travis::Database.connect
|
||||
|
||||
branches = Hash.new { |h, k| h[k] = [] }
|
||||
|
||||
Build.pushes.includes(:commit).find_in_batches do |builds|
|
||||
builds.each do |build|
|
||||
#next if build.branch
|
||||
branches[build.commit.branch] << build.id
|
||||
end
|
||||
end
|
||||
|
||||
branches.each do |branch, ids|
|
||||
Build.where(id: ids).update_all(branch: branch)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user