Commit 43524289 authored by Paul Asmuth's avatar Paul Asmuth
Browse files

numtimeseries report wip

parent 17e5dc18
Loading
Loading
Loading
Loading
+11 −11
Original line number Diff line number Diff line
@@ -2,17 +2,17 @@
  "klass": "NumericTimeseriesReport",
  "since": 1336873946,
  "until": 1336879946,
  "config": {
    "ticks": [10, 30, 60],
  "query": "filter(_type & 'search_with_filter','search_without_filter')",
  "series": {
    "with_filter": {
      "title": "Searches with Filter",
        "query": "filter(_type = 'search_with_filter')"
      "query": "filter(_type = 'search_with_filter')",
      "multisample_key": false
    },
    "without_filter": {
      "title": "Searches with Filter",
        "query": "filter(_type = 'search_without_filter')"
      }
      "query": "filter(_type = 'search_without_filter')",
      "multisample_key": false
    }
  }
}
 No newline at end of file
+3 −0
Original line number Diff line number Diff line
class FnordQuery::Report

  def initialize(opts)
  	@opts = opts
  end

end
 No newline at end of file
+36 −2
Original line number Diff line number Diff line
class FnordQuery::NumericTimeseriesReport < FnordQuery::Report

  def execute(runner, backend)
  def execute(runner, _backend)
  	backend = _backend[0].new(_backend[1])

  	t_since = @opts["since"].to_i
  	t_until = @opts["until"].to_i

  	@tick = (t_until - t_since) / 150

  	@timeline = Hash[149.times.inject([t_until]) do |a, n|
  	  a + [a.last - n*@tick]
  	end.map do |t|
  	  [t, 0]
	end]

  	query = FnordQuery::Query.new("#{@opts["query"]} since(#{t_since}) until(#{t_until})")

  	backend.on_finish do
  	  render_result
  	  runner.send(:shutdown, true)
  	end

  	backend.subscribe(query) do |event|

  	  (event["_time"]-@tick..event["_time"]).to_a.detect do |t|
  	  	if @timeline.has_key?(t)
          @timeline[t] += 1
  	  	end
  	  end

  	end
  end

private

  def render_result
  	puts @timeline.inspect
  end

end
 No newline at end of file
+3 −2
Original line number Diff line number Diff line
@@ -18,9 +18,10 @@
    <div class="viewport_inner clearfix">

      <div class="navbar" style="margin-bottom:24px;">
        <a class="button">Export Data</a>
        <a class="button">Dropdown: Range selector / cached ranges</a>
        <a class="button">Configure</a>
        <a class="button back">&laquo;</a>
        <h1><a>Fnord / </a><a class="current">Live Search Queries</a></h1>
        <h1><a class="current">Gross Search Volume</a> &nbsp; <a>(07.05.12-15.05.12)</a></h1>
      </div>
    
      <iframe src="test.html" width="100%" height="1500" scrolling="no" frameborder="none"></iframe>