Permalink
Browse files

Round days syntax sugar to full days

  • Loading branch information...
1 parent 34f1dd3 commit 243e689b4d92f2d3dfb67345e1441ee9dc255e58 @sixtus sixtus committed Apr 5, 2013
Showing with 9 additions and 6 deletions.
  1. +1 −1 README.md
  2. +8 −5 lib/druid/query.rb
View
@@ -51,7 +51,7 @@ $ bin/dripl
:timeZone => "Europe/Berlin"
},
:intervals => [
- [0] "2013-03-28T11:57:20+01:00/2013-04-04T11:57:20+02:00"
+ [0] "2013-03-28T00:00:00+01:00/2013-04-04T11:57:20+02:00"
],
:queryType => :groupBy,
:aggregations => [
View
@@ -14,8 +14,11 @@ def initialize(source, client = nil)
data_source(source)
granularity(:all)
- today = Time.at ((Time.now.to_i / 86400.0).floor * 86400)
- interval(today, today + 86400)
+ interval(today)
+ end
+
+ def today
+ Time.now.to_date.to_time
end
def send
@@ -88,8 +91,8 @@ def filter(hash = nil, &block)
end
def interval(from, to = Time.now)
- from = Time.now + from if from.is_a?(Fixnum)
- to = Time.now + to if to.is_a?(Fixnum)
+ from = today + from if from.is_a?(Fixnum)
+ to = today + to if to.is_a?(Fixnum)
from = DateTime.parse(from.to_s) unless from.respond_to? :iso8601
to = DateTime.parse(to.to_s) unless to.respond_to? :iso8601
@@ -196,7 +199,7 @@ def to_json(*a)
class FilterParameter
(instance_methods + private_instance_methods).each do |method|
- unless method.to_s =~ /^(__|instance_eval|instance_exec|initialize|object_id|raise|puts|inspect)/ || method.to_s =~ /\?/
+ unless method.to_s =~ /^(__|instance_eval|instance_exec|initialize|object_id|raise|puts|inspect|class)/ || method.to_s =~ /\?/
undef_method method
end
end

0 comments on commit 243e689

Please sign in to comment.