lib/google_otg.rb in google_otg-1.0.16 vs lib/google_otg.rb in google_otg-1.0.17
- old
+ new
@@ -2,11 +2,11 @@
require 'gchart_mod'
require 'uri'
module GoogleOtg
- DEFAULT_RANGE = 30 # 30 min
+ DEFAULT_RANGE = 1 # 1 day
def google_line_graph(hits, args = {})
raise ArgumentError, "Invalid hits" unless hits && hits.length > 0
@@ -235,21 +235,21 @@
points = []
point_dates = []
now_days = tz.now # use this get the right year, month and day
- now_minutes = tz.at((now_days.to_i/(60*range))*(60*range)).gmtime
+ now_minutes = tz.at((now_days.to_i/(60*(range * 1440)))*(60*(range * 1440))).gmtime
now_floored = tz.local(now_days.year, now_days.month, now_days.day,
now_minutes.hour, now_minutes.min, now_minutes.sec)
if args[:lower_bound_time]
current = time_fn.call(args[:lower_bound_time])
else
current = hits.length > 0 ? time_fn.call(hits[0]) : now_floored
end
- while (current < now_floored + range.minutes && range > 0) do
+ while (current < now_floored + range.days && range > 0) do
if hits_dict[current]
count = hits_dict[current].count.to_i
max_y = count if count > max_y
date = time_fn.call(hits_dict[current])
@@ -266,10 +266,10 @@
points.push(points_fn.call(0, date_key, date_value))
end
# Save the date for the x labels later
point_dates.push({:key => date_key, :value => date_value})
- current = current + range.minutes
+ current = current + range.days
break if points.length > 100
end
## Setup Y axis labels ##
max_y = args.has_key?(:max_y) ? (args[:max_y] > max_y ? args[:max_y] : max_y) : max_y
\ No newline at end of file