Skip to content

Instantly share code, notes, and snippets.

@airspeed
Last active October 27, 2015 16:06
Show Gist options
  • Save airspeed/bdbf1d7419d0cd1b7c19 to your computer and use it in GitHub Desktop.
Save airspeed/bdbf1d7419d0cd1b7c19 to your computer and use it in GitHub Desktop.
q = Source.where( :code => 'telekom_mega_deal' ).last
gs = Voucher.where( :source_id => q.id ) # Deal2015
ios = Order.where( :state => :printed.to_s, :voucher_id => gs, :client_id => 5 ).map( &:total_amount ).sum.to_f
android = Order.where( :state => :printed.to_s, :voucher_id => gs, :client_id => 4 ).map( &:total_amount ).sum.to_f
Order.where( :state => :printed.to_s, :voucher_id => gs, :client_id => 5 ).count
Order.where( :state => :printed.to_s, :voucher_id => gs ).select{ | w | w.user.orders.where( :state => :printed.to_s ).first.id == w.id if w.user
}.select{ | w | w.user.mobile_operator_id == 1 }.count
Order.where( :state => :printed.to_s, :voucher_id => gs ).select{ | w | w.user.orders.where( :state => :printed.to_s ).first.id != w.id if w.user
}.select{ | w | w.user.mobile_operator_id != 1 }.count
Order.where( :state => :printed.to_s, :voucher_id => gs ).select{ | w | w.user.orders.where( :state => :printed.to_s ).first.id == w.id if w.user
}.select{ | w | CampaignUser.where( :user_id => w.user_id, :campaign_id => 1 ).count.nonzero? }.count
Order.where( :state => :printed.to_s, :voucher_id => gs ).select{ | w | w.user.orders.where( :state => :printed.to_s ).first.id != w.id if w.user
}.select{ | w | CampaignUser.where( :user_id => w.user_id, :campaign_id => 1 ).count.nonzero? }.count
Copy link

ghost commented Oct 23, 2015

kikel emelni, és lekel írni,,?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment