Class: MixReader::Events

Inherits:
Base
  • Object
show all
Defined in:
lib/mix_reader/events.rb

Constant Summary collapse

EVENT_SELECTORS =
%w(from_date to_date event_selectors)
JQL_SCRIPT_MAIN =
'PARAMS function main(){return Events(params)}'
JQL_SCRIPT_PARAMS =
"params = PARAMS_HASH;"

Constants inherited from Base

Base::MIXPANEL_JQL_URL

Instance Attribute Summary collapse

Attributes inherited from Base

#filters, #options, #script

Instance Method Summary collapse

Methods inherited from Base

query, #query

Constructor Details

#initialize(args) ⇒ Events

Returns a new instance of Events.



9
10
11
12
# File 'lib/mix_reader/events.rb', line 9

def initialize(args)
  super
  extract_selectors
end

Instance Attribute Details

#selectorsObject

Returns the value of attribute selectors.



7
8
9
# File 'lib/mix_reader/events.rb', line 7

def selectors
  @selectors
end

Instance Method Details

#build_scriptObject



14
15
16
17
# File 'lib/mix_reader/events.rb', line 14

def build_script
  params = JQL_SCRIPT_PARAMS.sub("PARAMS_HASH", selectors)
  @script = JQL_SCRIPT_MAIN.sub("PARAMS", params)
end

#extract_selectorsObject



19
20
21
22
23
24
25
26
# File 'lib/mix_reader/events.rb', line 19

def extract_selectors
  query_filters = {}
  EVENT_SELECTORS.each do |key|
    value = self.filters.delete(key.to_sym)
    query_filters[key.to_sym] = value unless value.nil?
  end
  @selectors = query_filters.to_json
end