Commit 8be8e44e authored by Paul Asmuth's avatar Paul Asmuth
Browse files

session_view integration wip (3)

parent 08da9f03
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -194,7 +194,7 @@ end

FnordMetric.options = {
  :event_queue_ttl  => 10, # all data that isn't processed within 10s is discarded to prevent memory overruns
  :event_data_ttl   => 10,
  :event_data_ttl   => 3600, # event data is stored for one hours (needed for the active users view)
  :session_data_ttl => 1,  # we don't care about session data for now
  :redis_prefix => "fnordmetric"
}
+6 −1
Original line number Diff line number Diff line
@@ -7,14 +7,19 @@ module FnordMetric
    #end

    def self.all(opts)
      opts[:limit] ||= 100

      range_opts = { :withscores => true }
      range_opts.merge!(:limit => [0,opts[:limit]]) if opts[:limit]

      events = opts[:redis].zrevrangebyscore(
        "#{opts[:namespace_prefix]}-timeline", 
        '+inf', opts[:since]||'0',
        range_opts
      )

      events = events[0..opts[:limit] - 1]

      unless events.first.is_a?(Array)
        events = events.in_groups_of(2).map do |event_id, ts|
          [event_id, Float(ts)]
+13 −2
Original line number Diff line number Diff line
@@ -52,10 +52,21 @@ private
  end

  def active_users(namespace, event)
    puts "FUBAR"
    namespace.ready!(@redis)

    events = if event["filter_by_type"]
      namespace.events(:by_type, :type => event["type"])
    elsif event["filter_by_session_key"]
      namespace.events(:by_session_key, :session_key => params["session_key"])
    else
      find_opts = { :limit => 100 }
      find_opts.merge!(:since => event["since"].to_i+1) if event["since"]
      namespace.events(:all, find_opts)
    end

    {
      :type => "active_users_response"
      :type => "active_users_response",
      :events => events.map(&:to_json)
    }
  end

+2 −1
Original line number Diff line number Diff line
@@ -222,10 +222,11 @@ var FnordMetric = (function(){
      } else if (!!window.location.hash.match(/^#gauge\/[a-zA-Z_0-9-]+$/)){
        elem = $('#sidebar li.gauge[data-token="'+window.location.hash.slice(7)+'"]');
      } else if(window.location.hash == "#active_users") {
        navigatedViaHash = true;
        renderSessionView();
      }

      if (elem.length > 0) {
      if (elem && (elem.length > 0)) {
        navigatedViaHash = true;
        elem.click();
      }
+5 −5

File changed.

Contains only whitespace changes.