class Octo::UserTimeline
Constants
- ADD_TO_CART
- APP_CLOSE
- APP_OPEN
- BROWSE_PAGE
- BROWSE_PRODUCT
- CHECKOUT
- LOC_HOME
- LOC_OFFICE
- LOC_OOH
- LOC_OTHERS
- LOC_TRANSIT
- LOC_VACATION
- PAGE_RELOAD
- SEARCH
- SHARE
Public Class Methods
fakedata(user, n = rand(7..20))
click to toggle source
# File lib/octocore-mongo/models/user/user_timeline.rb, line 37 def self.fakedata(user, n = rand(7..20)) Array.new(3*n) do |i| i+1 end.shuffle.sample(n).sort.reverse.collect do |i| args = { user: user, ts: i.minutes.ago, type: rand(0..8), title: 'Product Name', location_type: rand(11..16), insight: 'some valueable insight', details: 'other details here' } self.new(args).save! end end
Public Instance Methods
human_readable()
click to toggle source
# File lib/octocore-mongo/models/user/user_timeline.rb, line 94 def human_readable args = { user: self.user, ts: self.ts, type: type_text(self.type), type_raw: self.type, title: self.title, location: location_text(self.location_type), location_raw: self.location_type, insight: self.insight, details: self.details } OpenStruct.new(args) end
location_text(location_type)
click to toggle source
# File lib/octocore-mongo/models/user/user_timeline.rb, line 54 def location_text(location_type) case location_type when LOC_HOME 'Home' when LOC_OFFICE 'Office' when LOC_TRANSIT 'In Transit' when LOC_VACATION 'While Vacation' when LOC_OOH 'Out of Home City' when LOC_OTHERS 'Other Location' end end
type_text(activity_type)
click to toggle source
# File lib/octocore-mongo/models/user/user_timeline.rb, line 71 def type_text(activity_type) case activity_type when BROWSE_PRODUCT 'Browsed for Product' when BROWSE_PAGE 'Browsed for Page' when SEARCH 'Searched' when SHARE 'Shared' when ADD_TO_CART 'Added to Cart' when CHECKOUT 'Performed Checkout' when APP_OPEN 'Opened App' when APP_CLOSE 'Closed App' when PAGE_RELOAD 'Reloaded Page' end end