Skip to content

Instantly share code, notes, and snippets.

@austindoeswork
Created February 15, 2018 19:07
Show Gist options
  • Save austindoeswork/c3939e7a1fa0b0d4df4fdbc66bded39d to your computer and use it in GitHub Desktop.
Save austindoeswork/c3939e7a1fa0b0d4df4fdbc66bded39d to your computer and use it in GitHub Desktop.
ids = Event.all.pluck(:id)
update_ids = EventUpdate.all.pluck(:event_id)
ids = ids - update_ids
puts "Got ID's"
id_length = ids.length # 4629062 !! holy shit
# i'll take the heat for this one
my_id = ContractorUser.find_by(email: "wilsonaustin17@gmail.com").id
ids.each_with_index do |id, i|
id, call_id, skill_ids = Event.select(:id, :call_id, :skill_ids)
.find_by(id: id)
.attributes.values
transcriber_id, scorer_id = Call.select(:transcriber_id, :scorer_id)
.find_by(id: call_id)
.attributes.values
up_id = my_id
if !scorer_id.nil?
up_id = scorer_id
elsif !transcriber_id.nil?
up_id = transcriber_id
end
EventUpdate.create(event_id: id,
updater_id: up_id,
updater_type: "contractor_user",
skill_ids: skill_ids || [])
if i % 1000 == 0
puts "#{i} / #{id_length}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment