armandofox/audience1st

View on GitHub
app/models/reports/all_subscribers.rb

Summary

Maintainability
A
15 mins
Test Coverage
A
100%
class AllSubscribers < Report

  def initialize(output_options = {})
    @view_params = {
      :name => 'All subscribers',
      :vouchertypes => Vouchertype.subscription_vouchertypes()
    }
    super
  end

  def generate(params = {})
    add_error("Please specify one or more subscriber voucher types.") and return if (vouchertypes = params[:vouchertypes]).blank?
    vouchertypes = Report.list_of_ints_from_multiselect(params[:vouchertypes])
    @relation = Customer.regular_customers.purchased_any_vouchertypes(vouchertypes) 
  end
end