Skip to content

Instantly share code, notes, and snippets.

@nicolasmarcal
nicolasmarcal / gist:1603e98f4eb2cc3e7732
Created December 26, 2014 18:36
Update ABR plans to gold plus kind
Plan.all.each do |plan|
unless plan.plus_kind == "platinum"
puts "plan_id => #{plan.id}, :kind_was => #{plan.plus_kind}"
plan.update_attributes(:plus_kind => "gold")
end
end
plan_id => 52, :kind_was => regular
plan_id => 53, :kind_was => regular
plan_id => 54, :kind_was => regular
@nicolasmarcal
nicolasmarcal / gist:e35f64c8bdd57c2106d1
Last active August 29, 2015 14:20
Arruma data de pagamento da porto seguro
File.open("log/change_bill_at_of_membership_recurrency.log", "w") do |file|
Membership.transaction do
location = Location.find_by_acronym("POR")
membership_recurrencies = MembershipRecurrency.find(location.active_memberships.map(&:membership_recurrency_id).uniq).select{ |mr| mr.bill_day != 1 }
membership_recurrencies.each do |membership_recurrency|
membership = membership_recurrency.memberships.active.first
file.puts "#{membership.person.id};#{membership.person.name};"
old_bill_day = membership_recurrency.bill_day
changer = BillAtChanger.new(membership, 1)
# -*- encoding : utf-8 -*-
[Date.parse("2015-05-01"), Date.parse("2015-04-01")].each do |date|
Octopus.each do
Location.bioritmo_or_franchising.each do |location|
book = Spreadsheet::Workbook.new
sheet1 = book.create_worksheet(:name => "Geral")
sheet1.row(0).concat %w{CONSULTOR VENDAS META PORCENTAGEM COMISSÃO}
goals = location.goals.sales.find(:all, :conditions => { :date => date })
location_goal = Goal.new(:location_id => location.id, :kind => :sales, :date => date)
Octopus.each do
Location.bioritmo.each do |location|
plan = location.plans.where("name like '%Winter Pass%'").last
if plan
puts location.name
puts plan.memberships.map(&:purchase).compact.flat_map(&:payments).select{|p| p.external_transaction_code.nil? || p.external_transaction_code == "1"}.map(&:id)
end
end
end;nil
def show_attribute_diff(version, attr_name)
changeset = version.changeset.fetch(attr_name, "Sem Alterações")
if no_diff?(changeset)
"Sem Alterações"
else
"DE:#{default_string_when_nil(changeset[0])} PARA:#{default_string_when_nil(changeset[1])}".html_safe
end
end
def show_price_diff(version)
File.open("taxons_report.csv", "w") do |file|
file.puts "SKU;NOME;CATEGORIAS"
Spree::Variant.all.each do |variant|
file.puts "#{variant.sku};#{variant.product.name};#{variant.product.taxons.map(&:name).join(';')}"
end
end;nil
Spree::Product.update_all(zoom_enabled: true)