Class: SpreeCmCommissioner::PieChartEventAggregatorQueries
- Inherits:
-
Object
- Object
- SpreeCmCommissioner::PieChartEventAggregatorQueries
- Defined in:
- app/queries/spree_cm_commissioner/pie_chart_event_aggregator_queries.rb
Instance Attribute Summary collapse
-
#chart_type ⇒ Object
readonly
Returns the value of attribute chart_type.
-
#refreshed ⇒ Object
readonly
Returns the value of attribute refreshed.
-
#taxon_id ⇒ Object
readonly
Returns the value of attribute taxon_id.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(taxon_id:, chart_type:, refreshed: false) ⇒ PieChartEventAggregatorQueries
constructor
chart_type: ‘participation | gender | entry_type’ taxon_id: taxon_id, refreshed: false.
- #pie_chart_aggregators ⇒ Object
Constructor Details
#initialize(taxon_id:, chart_type:, refreshed: false) ⇒ PieChartEventAggregatorQueries
chart_type: ‘participation | gender | entry_type’ taxon_id: taxon_id, refreshed: false
6 7 8 9 10 |
# File 'app/queries/spree_cm_commissioner/pie_chart_event_aggregator_queries.rb', line 6 def initialize(taxon_id:, chart_type:, refreshed: false) @taxon_id = taxon_id @chart_type = chart_type || 'participation' @refreshed = refreshed end |
Instance Attribute Details
#chart_type ⇒ Object (readonly)
Returns the value of attribute chart_type.
3 4 5 |
# File 'app/queries/spree_cm_commissioner/pie_chart_event_aggregator_queries.rb', line 3 def chart_type @chart_type end |
#refreshed ⇒ Object (readonly)
Returns the value of attribute refreshed.
3 4 5 |
# File 'app/queries/spree_cm_commissioner/pie_chart_event_aggregator_queries.rb', line 3 def refreshed @refreshed end |
#taxon_id ⇒ Object (readonly)
Returns the value of attribute taxon_id.
3 4 5 |
# File 'app/queries/spree_cm_commissioner/pie_chart_event_aggregator_queries.rb', line 3 def taxon_id @taxon_id end |
Instance Method Details
#call ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/queries/spree_cm_commissioner/pie_chart_event_aggregator_queries.rb', line 12 def call cache_key = "#{chart_type}-#{taxon_id}" Rails.cache.delete(cache_key) if refreshed product_charts = Rails.cache.fetch(cache_key, expires_in: 30.minutes) do pie_chart_aggregators || [] end SpreeCmCommissioner::PieChartEventAggregator.new( id: taxon_id, chart_type: chart_type, product_charts: product_charts ) end |
#pie_chart_aggregators ⇒ Object
27 28 29 30 31 32 33 |
# File 'app/queries/spree_cm_commissioner/pie_chart_event_aggregator_queries.rb', line 27 def pie_chart_aggregators case chart_type when 'participation' then participation_pie_chart when 'gender' then gender_pie_chart when 'entry_type' then entry_type_pie_chart end end |