Last active
October 19, 2016 05:49
-
-
Save purintai/da611bf1e33ee6a77abcb571d5e01800 to your computer and use it in GitHub Desktop.
touch or delete (if csv rows over 500k)
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
csv = CSV.open(path, headers: true) | |
touched = [] | |
csv.each do |row| | |
params = row.to_h | |
ProductUpdateWorker.perform_async(params) | |
touched << params['code'] | |
end | |
Product.where.not(code: touched).destroy_all |
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
csv = CSV.open(path, headers: true) | |
begin_at = Time.zone.now | |
csv.each do |row| | |
params = row.to_h | |
ProductUpdateWorker.perform_async(params) | |
Product.find_by(code: params['code'])&.touch | |
end | |
Product.where('updated_at < ?', begin_at).destroy_all |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
IN句はOracleだと1000要素までと言う制限があるし、そもそも50万要素あるIN句を投げるのはばかばかしい…