Method: Wco::SubscriptionsController#index

Defined in:
app/controllers/wco/subscriptions_controller.rb

#indexObject



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'app/controllers/wco/subscriptions_controller.rb', line 46

def index
  authorize! :index, Wco::Subscription

  @stripe_customers     = Stripe::Customer.list().data
  @stripe_subscriptions = Stripe::Subscription.list().data

  @customers     = {} ## still stripe customers
  customer_ids   = @stripe_customers.map &:id
  @leadsets      = Leadset.where( :customer_id.in => customer_ids )
  @leadsets.each do |i|
    @customers[i[:customer_id]] ||= {}
    @customers[i[:customer_id]][:leadsets] ||= []
    @customers[i[:customer_id]][:leadsets].push( i )
  end
  @profiles = Ish::UserProfile.where( :customer_id.in => customer_ids )
  @profiles.each do |i|
    @customers[i[:customer_id]] ||= {}
    @customers[i[:customer_id]][:profiles] ||= []
    @customers[i[:customer_id]][:profiles].push( i )
  end
  # puts! @customers, '@customers'

  @wco_subscriptions = Wco::Subscription.all

end