Skip to content

Instantly share code, notes, and snippets.

@nbarthelemy
Last active July 20, 2019 00:40
Show Gist options
  • Save nbarthelemy/08f59bf50e47577708b1a2cf3acc59c4 to your computer and use it in GitHub Desktop.
Save nbarthelemy/08f59bf50e47577708b1a2cf3acc59c4 to your computer and use it in GitHub Desktop.
# 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