Last active
July 20, 2019 00:40
-
-
Save nbarthelemy/08f59bf50e47577708b1a2cf3acc59c4 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
# delete all( 1st 50 ) orders including archived | |
ShopifyAPI::Order.find(:all, params: { status: 'any', fields: 'id' }).each{ |o| ShopifyAPI::Order.delete(o.id.to_i) } | |
# get all orders | |
count = ShopifyAPI::Order.count | |
page = 1 | |
collection = [] | |
while count > 0 do | |
collection << ShopifyAPI::Order.find(:all, params: { status: 'any', fields: 'id', page: page }) | |
count = count - 50 | |
page = page + 1 | |
end | |
collection.flatten! | |
# delete all orders | |
collection.each{ |o| ShopifyAPI::Order.delete(o.id.to_i) } | |
# get all products | |
count = ShopifyAPI::Product.count | |
page = 1 | |
collection = [] | |
while count > 0 do | |
collection << ShopifyAPI::Product.find(:all, params: { page: page }) | |
count = count - 50 | |
page = page + 1 | |
end | |
collection.flatten! | |
# drip remove all .ru addresses | |
d = MigrationAssistant::Base.drip | |
response = d.subscribers | |
count = response.meta['total_count'] | |
page = response.meta['page'] | |
collection = response.subscribers | |
while count > 0 do | |
puts "page : #{page}" | |
collection.select{|s| s.email.match?(/\.ru$/) }.each do |s| | |
puts "deleteing #{s.email}" | |
d.delete_subscriber(s.email) | |
end | |
count = count - response.meta['count'] | |
page = page + 1 | |
response = d.subscribers(page: page) | |
collection = response.subscribers | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment