Class: Spree::Api::V2::Operator::EventChartsController
- Inherits:
-
ResourceController
- Object
- ResourceController
- Spree::Api::V2::Operator::EventChartsController
- Defined in:
- app/controllers/spree/api/v2/operator/event_charts_controller.rb
Constant Summary collapse
- ACCEPTED_KYC_FIELDS =
%i[guest_gender guest_occupation guest_nationality].freeze
- ADDITIONAL_FIELDS =
%i[participation entry_type].freeze
Instance Method Summary collapse
Instance Method Details
#index ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/controllers/spree/api/v2/operator/event_charts_controller.rb', line 9 def index kyc_fields = fetch_filtered_kyc_fields types = ADDITIONAL_FIELDS + kyc_fields resources = types.map do |type| event_chart = SpreeCmCommissioner::EventChartQueries.new( taxon_id: params[:taxon_id], chart_type: type, refreshed: params[:refreshed] || false ).call # Create unique ID by using chart_type as the identifier SpreeCmCommissioner::EventChart.new( id: type.to_s, chart_type: event_chart.chart_type, product_charts: event_chart.product_charts ) end render json: SpreeCmCommissioner::V2::Operator::PieChartEventAggregatorSerializer.new(resources).serializable_hash end |
#resource ⇒ Object
31 32 33 |
# File 'app/controllers/spree/api/v2/operator/event_charts_controller.rb', line 31 def resource @resource = event_chart_aggregator_queries.call end |
#resource_serializer ⇒ Object
35 36 37 |
# File 'app/controllers/spree/api/v2/operator/event_charts_controller.rb', line 35 def resource_serializer SpreeCmCommissioner::V2::Operator::PieChartEventAggregatorSerializer end |