Created
July 31, 2016 14:54
-
-
Save thedrow/ac40f01abbffcb822f52d3c9a615fdcb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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