Class: Blackbeard::Cohort
Instance Attribute Summary
Attributes inherited from Storable
#id, #new_record
Instance Method Summary
collapse
Methods included from Chartable
#recent_days, #recent_days_chart, #recent_hours, #recent_hours_chart
Methods inherited from Storable
#==, all, all_keys, count, create, find, find_or_create, #initialize, #key, key_for, #master_key, master_key, new_from_key, new_from_keys, #new_record?, on_reload, on_reload_methods, on_save, on_save_methods, #reload, #save, set_master_key
included
included
included
#config, #db, #guest_method, included, #tz
Instance Method Details
#add(context, timestamp = nil, force = false) ⇒ Object
11
12
13
14
15
16
17
|
# File 'lib/blackbeard/cohort.rb', line 11
def add(context, timestamp = nil, force = false)
save if new_record?
uid = context.unique_identifier
timestamp ||= tz.now
return (force) ? data.add_with_force(uid, timestamp) : data.add_without_force(uid, timestamp)
end
|
#chartable_result_for_day(date) ⇒ Object
43
44
45
|
# File 'lib/blackbeard/cohort.rb', line 43
def chartable_result_for_day(date)
{'participants' => data.participants_for_day(date) }
end
|
#chartable_result_for_hour(hour) ⇒ Object
39
40
41
|
# File 'lib/blackbeard/cohort.rb', line 39
def chartable_result_for_hour(hour)
{'participants' => data.participants_for_hour(hour) }
end
|
#chartable_segments ⇒ Object
35
36
37
|
# File 'lib/blackbeard/cohort.rb', line 35
def chartable_segments
['participants']
end
|
#data ⇒ Object
19
20
21
|
# File 'lib/blackbeard/cohort.rb', line 19
def data
@data ||= CohortData.new(self)
end
|
#hour_id_for_participant(uid) ⇒ Object
31
32
33
|
# File 'lib/blackbeard/cohort.rb', line 31
def hour_id_for_participant(uid)
data.hour_id_for_participant(uid)
end
|
#metric_data(metric) ⇒ Object
#name ⇒ Object
23
24
25
|
# File 'lib/blackbeard/cohort.rb', line 23
def name
storable_attributes_hash['name'] || id
end
|