This file contains hidden or 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
| [ | |
| { | |
| "formatId" : "ID_3", | |
| "title" : "formatInfoCompact", | |
| "shoppingCartTitle" : "shoppingcartInfoCompact", | |
| "photoCountText" : "shoppingcartInfo30Pics", | |
| "infoText" : "formatInfo30Pics", | |
| "typeLabelText" : "formatButtonCompact", | |
| "formatImage" : "Format-3", | |
| "price":15.50, |
This file contains hidden or 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
| ( 1 .. 20 ).each do | i | | |
| Voucher.create :code => "WoodBoard#{i}", :quantity => 151, :value => 10, :discount_type => 'NUMBER', :valid_from => Date.today, :valid_until => Date. | |
| parse('2016-01-31'), :shipping_discount => false, :settings => { :products_limit => [ "clxkp002" ] } | |
| Voucher.last.tap{ | g | g.settings = { :products_limit => ["CLXKP002"] } }.save | |
| end | |
| ( 1 .. 15 ).each do | i | | |
| Voucher.create :code => "wood#{i}", :quantity => 500, :value => 25, :discount_type => 'PERCENT', :valid_from => Date.today, :valid_until => Date. | |
| parse('2015-12-31'), :shipping_discount => false, :settings => { :products_limit => [ "all" ] } | |
| end |
This file contains hidden or 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
| # Vgl. #5711 | |
| # date_from - date range start | |
| # date_until - date range end | |
| # custom_search - flag freeze search dates | |
| def vouchers_report( date_from = Date.yesterday , date_until = Date.today, custom_search = false ) | |
| date_from = Date.today - 3.days if Date.today.wday == 1 && !custom_search # Montags alle Wochenendebestellungen mit reinbeziehen. | |
| product_codes = [ 'CLXPXV01', 'CLXPXV02', 'CLXPXV03', 'CLXPXV04' ] | |
| Order.where( :state => :printed.to_s, :created_at => date_from .. date_until ).select{ | w | w.order_items.any?{ | i | product_codes.include?( i.product_code ) } }.map{ | w | [ w.id, ( w.user.email if w.user ), w.created_at.to_date.to_s ] } | |
| end | |
| # vouchers_report Date.today.beginning_of_month - 1.month, Date.today.beginning_of_month, true |
This file contains hidden or 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 classes_user_auto ( classes, from, to ) | |
| results = [] | |
| classes.each do | range | | |
| os = Order.where( :state => :printed.to_s, :created_at => from .. to ).group( :user_id ).having( "count(*) >= #{ range.first } AND count(*) <= #{ range.last }" ) | |
| n = os.count.count | |
| t = os.sum( :amount_eu ).sum{ | k, v | v }.to_f.round( 2 ) | |
| results << [ "#{ from .. to }", "#{ range }", n, t ] | |
| end | |
| results | |
| end |
This file contains hidden or 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
| # !#crm | |
| def make_stats | |
| emails = Set.new | |
| stats = [] | |
| Customer.find_each do | k | | |
| emails.add?( k.email ) or next # customer already reported | |
| all_cs = Customer.where( :email => k.email ) | |
| all_os = all_cs.map( &:order_carts ) | |
| all_os.select{ | order_list | order_list.count > 0 }.count > 1 or next # this customer is NOT a rebuyer -> skip | |
| first_order_id = all_os.map{ | w | w.select(" MIN( id ) AS first_order_id ").group( :app_id ).map( &:first_order_id ) }.map( &:first ).min |
This file contains hidden or 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 cs16 | |
| result = [] | |
| ps = [ 'PLBF6S1F', 'PLBF5S1F', 'PLBF4S1F', 'PLBF3S1F', 'PLBFXBX1'] | |
| is = OrderItem.where( :product_code => ps ) | |
| uids = is.map( &:user_id ).uniq | |
| iids = is.map( &:id ).uniq # eigentlich unnötig, aber schadet ja nicht | |
| oids = is.map( &:order_id ).uniq | |
| result << [ 'User ID', 'User Email', 'Anzahl Bestellungen', 'Gesamtbestellwert', 'Bestellte Produkte' ] | |
| uids.each do | uid | | |
| u = User.where( :id => uid ).last or next |
This file contains hidden or 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
| # vps-api | |
| ANDROID_CLIENT_ID = 4 | |
| IOS_CLIENT_ID = 5 | |
| TELEKOM_CAMPAIGN_APRIL_2016_CAMPAIGN_ID = 4 | |
| ################################################################################ | |
| # orders from April 18 to May 10 2016: | |
| ################################################################################ | |
| os = Order.where( :state => :printed.to_s, :created_at => Date.parse('2016-04-18') .. Date.parse('2016-05-11') ) |
This file contains hidden or 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
| require "nokogiri" | |
| def nokogiri_edit( handle, opts ) | |
| builder = Nokogiri::XML::Builder.new( :encoding => 'UTF-8' ) do | xml | | |
| party = false | |
| party_id = false | |
| party_id_system = false | |
| party_id_match = false | |
| party_role = false |
This file contains hidden or 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
| require "nokogiri" | |
| def nokogiri_edit( handle, opts ) | |
| doc = Nokogiri::XML( handle ) | |
| # address update | |
| if opts[ :address ] # start address | |
| updated_address = opts[ :address ] | |
| address = doc.xpath( |
This file contains hidden or 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 alex( t0 = Date.yesterday, t1 = Date.tomorrow, limit = 12 ) | |
| dt = t0 .. t1 | |
| median = [] | |
| Order.where( :state => :printed.to_s, :created_at => dt ).find_each do | w | | |
| qty = w.order_items.select{ | i | i.product_code == "CLXPXS1F" }.map( &:quantity ).sum | |
| median << qty | |
| end | |
| # puts median | |
| a1 = median.select{ | i | i < limit }.count | |
| # Median |