Skip to content

Instantly share code, notes, and snippets.

@thedrow
Created July 31, 2016 14:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thedrow/ac40f01abbffcb822f52d3c9a615fdcb to your computer and use it in GitHub Desktop.
Save thedrow/ac40f01abbffcb822f52d3c9a615fdcb to your computer and use it in GitHub Desktop.
def dump_ar_relation(relation)
if !DEBUG
cleaned_relation = clean_objects(relation)
$pool.post do
begin
dumped_data = SeedDump.dump(cleaned_relation, batch_size: 1000, exclude: EXCLUDE_FIELDS, import: true, import_options: { validate: false, on_duplicate_key_update: [:id] }) if cleaned_relation.any?
next unless dumped_data
$file_writer.post do
#$fiverr_dev_seed_file.flock(File::LOCK_EX | File::LOCK_NB)
$fiverr_dev_seed_file.write(dumped_data)
#$fiverr_dev_seed_file.flock(File::LOCK_UN)
end
rescue => e
$log.error e.message
end
end
end
rescue
nil
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment