class Rack::MiniProfiler::AbstractStore

Constants

MAX_TOKEN_AGE

maximum age of allowed tokens before cycling in seconds

Public Instance Methods

allowed_tokens() click to toggle source

a list of tokens that are permitted to access profiler in explicit mode

# File lib/mini_profiler/storage/abstract_store.rb, line 40
def allowed_tokens
  raise NotImplementedError.new("allowed_tokens is not implemented")
end
diagnostics(user) click to toggle source
# File lib/mini_profiler/storage/abstract_store.rb, line 34
def diagnostics(user)
  # this is opt in, no need to explode if not implemented
  ""
end
fetch_snapshots_group(group_name) click to toggle source

@param group_name [String] @return [Array<Rack::MiniProfiler::TimerStruct::Page>] list of snapshots of the group. Blank array if the group doesn’t exist.

# File lib/mini_profiler/storage/abstract_store.rb, line 63
def fetch_snapshots_group(group_name)
  raise NotImplementedError.new("fetch_snapshots_group is not implemented")
end
fetch_snapshots_overview() click to toggle source

returns a hash where the keys are group names and the values are hashes that contain 3 keys:

1. `:worst_score` => the duration of the worst/slowest snapshot in the group (float)
2. `:best_score` => the duration of the best/fastest snapshot in the group (float)
3. `:snapshots_count` => the number of snapshots in the group (integer)
# File lib/mini_profiler/storage/abstract_store.rb, line 57
def fetch_snapshots_overview
  raise NotImplementedError.new("fetch_snapshots_overview is not implemented")
end
get_unviewed_ids(user) click to toggle source
# File lib/mini_profiler/storage/abstract_store.rb, line 30
def get_unviewed_ids(user)
  raise NotImplementedError.new("get_unviewed_ids is not implemented")
end
load(id) click to toggle source
# File lib/mini_profiler/storage/abstract_store.rb, line 14
def load(id)
  raise NotImplementedError.new("load is not implemented")
end
load_snapshot(id, group_name) click to toggle source
# File lib/mini_profiler/storage/abstract_store.rb, line 67
def load_snapshot(id, group_name)
  raise NotImplementedError.new("load_snapshot is not implemented")
end
push_snapshot(page_struct, group_name, config) click to toggle source
# File lib/mini_profiler/storage/abstract_store.rb, line 48
def push_snapshot(page_struct, group_name, config)
  raise NotImplementedError.new("push_snapshot is not implemented")
end
save(page_struct) click to toggle source
# File lib/mini_profiler/storage/abstract_store.rb, line 10
def save(page_struct)
  raise NotImplementedError.new("save is not implemented")
end
set_all_unviewed(user, ids) click to toggle source
# File lib/mini_profiler/storage/abstract_store.rb, line 26
def set_all_unviewed(user, ids)
  raise NotImplementedError.new("set_all_unviewed is not implemented")
end
set_unviewed(user, id) click to toggle source
# File lib/mini_profiler/storage/abstract_store.rb, line 18
def set_unviewed(user, id)
  raise NotImplementedError.new("set_unviewed is not implemented")
end
set_viewed(user, id) click to toggle source
# File lib/mini_profiler/storage/abstract_store.rb, line 22
def set_viewed(user, id)
  raise NotImplementedError.new("set_viewed is not implemented")
end
should_take_snapshot?(period) click to toggle source
# File lib/mini_profiler/storage/abstract_store.rb, line 44
def should_take_snapshot?(period)
  raise NotImplementedError.new("should_take_snapshot? is not implemented")
end
snapshots_group(group_name) click to toggle source
# File lib/mini_profiler/storage/abstract_store.rb, line 79
def snapshots_group(group_name)
  snapshots = fetch_snapshots_group(group_name)
  data = []
  snapshots.each do |snapshot|
    data << {
      id: snapshot[:id],
      duration: snapshot.duration_ms,
      sql_count: snapshot[:sql_count],
      timestamp: snapshot[:started_at],
      custom_fields: snapshot[:custom_fields]
    }
  end
  data.sort_by! { |s| s[:duration] }
  data.reverse!
  data
end
snapshots_overview() click to toggle source
# File lib/mini_profiler/storage/abstract_store.rb, line 71
def snapshots_overview
  groups = fetch_snapshots_overview.to_a
  groups.sort_by! { |name, hash| hash[:worst_score] }
  groups.reverse!
  groups.map! { |name, hash| hash.merge(name: name) }
  groups
end