Class: Spree::Api::V2::Operator::EventChartsController

Inherits:
ResourceController
  • Object
show all
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

#indexObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# 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|
    # Create unique ID by using chart_type as the identifier
    SpreeCmCommissioner::EventChart.new(
      id: type.to_s,
      chart_type: type,
      product_charts: nil
    )
  end

  render json: SpreeCmCommissioner::V2::Operator::PieChartEventAggregatorSerializer.new(resources).serializable_hash
end

#resourceObject



25
26
27
# File 'app/controllers/spree/api/v2/operator/event_charts_controller.rb', line 25

def resource
  @resource = event_chart_aggregator_queries.call
end

#resource_serializerObject



29
30
31
# File 'app/controllers/spree/api/v2/operator/event_charts_controller.rb', line 29

def resource_serializer
  SpreeCmCommissioner::V2::Operator::PieChartEventAggregatorSerializer
end