Class: Analytics::Util
- Inherits:
-
Object
- Object
- Analytics::Util
- Defined in:
- lib/analytics.rb
Class Method Summary collapse
-
.day_query_time ⇒ Object
get query time by hour method.
- .gather_data ⇒ Object
-
.hour_query_time ⇒ Object
get query time by hour method.
Class Method Details
.day_query_time ⇒ Object
get query time by hour method
69 70 71 72 73 74 75 |
# File 'lib/analytics.rb', line 69 def Util.day_query_time now = Time.new last_day_time = now-(60*60*24) last_day_start = Time.mktime(last_day_time.year,last_day_time.month,last_day_time.day,0,0,0).to_i last_day_end = last_day_start+(60*60*24)-1 return now.to_i*1000,last_day_start*1000,last_day_end*1000 end |
.gather_data ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/analytics.rb', line 46 def self.gather_data #Fetch all sites sites = [] Analytics.client.query("select id from sites").each{|r| sites << r[0]} #Gather day visitor data sites.each{|site_id| begin yield(site_id) rescue => err puts err # TODO 自动发送错误信息 end } end |
.hour_query_time ⇒ Object
get query time by hour method
61 62 63 64 65 66 67 |
# File 'lib/analytics.rb', line 61 def Util.hour_query_time now = Time.new last_hour_time = now-(60*60) last_hour_start = Time.mktime(last_hour_time.year,last_hour_time.month,last_hour_time.day,last_hour_time.hour,0,0).to_i last_hour_end = last_hour_start+(60*60)-1 return now.to_i*1000,last_hour_start*1000,last_hour_end*1000 end |