Class: SpreeCmCommissioner::EventChartQueries
- Inherits:
-
Object
- Object
- SpreeCmCommissioner::EventChartQueries
- Defined in:
- app/queries/spree_cm_commissioner/event_chart_queries.rb
Instance Attribute Summary collapse
-
#chart_type ⇒ Object
readonly
Returns the value of attribute chart_type.
-
#check_in_session_id ⇒ Object
readonly
Returns the value of attribute check_in_session_id.
-
#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
- #event_chart ⇒ Object
-
#initialize(taxon_id:, chart_type:, check_in_session_id: nil, refreshed: false) ⇒ EventChartQueries
constructor
chart_type: 'participation | gender | entry_type' taxon_id: taxon_id, refreshed: false check_in_session_id: scopes check-in counts to a single session.
Constructor Details
#initialize(taxon_id:, chart_type:, check_in_session_id: nil, refreshed: false) ⇒ EventChartQueries
chart_type: 'participation | gender | entry_type' taxon_id: taxon_id, refreshed: false check_in_session_id: scopes check-in counts to a single session. When nil, a guest is counted once regardless of how many sessions they checked into.
8 9 10 11 12 13 |
# File 'app/queries/spree_cm_commissioner/event_chart_queries.rb', line 8 def initialize(taxon_id:, chart_type:, check_in_session_id: nil, refreshed: false) @taxon_id = taxon_id @chart_type = chart_type || 'participation' @check_in_session_id = check_in_session_id.presence @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/event_chart_queries.rb', line 3 def chart_type @chart_type end |
#check_in_session_id ⇒ Object (readonly)
Returns the value of attribute check_in_session_id.
3 4 5 |
# File 'app/queries/spree_cm_commissioner/event_chart_queries.rb', line 3 def check_in_session_id @check_in_session_id end |
#refreshed ⇒ Object (readonly)
Returns the value of attribute refreshed.
3 4 5 |
# File 'app/queries/spree_cm_commissioner/event_chart_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/event_chart_queries.rb', line 3 def taxon_id @taxon_id end |
Instance Method Details
#call ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/queries/spree_cm_commissioner/event_chart_queries.rb', line 15 def call cache_key = [chart_type, taxon_id, check_in_session_id].compact.join('-') Rails.cache.delete(cache_key) if refreshed product_charts = Rails.cache.fetch(cache_key, expires_in: 30.minutes) do event_chart || [] end SpreeCmCommissioner::EventChart.new( id: taxon_id, chart_type: chart_type, product_charts: product_charts ) end |
#event_chart ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'app/queries/spree_cm_commissioner/event_chart_queries.rb', line 30 def event_chart case chart_type when 'participation' then participation_event_chart when 'entry_type' then entry_type_event_chart when 'guest_gender' then gender_event_chart when 'guest_occupation' then occupation_event_chart when 'guest_nationality' then nationality_event_chart end end |