Sha256: 74dbb663ecd4c17bc8a9b2e27cf861766e734db495712e3ea1932950d74f5e7a

Contents?: true

Size: 1.28 KB

Versions: 2

Compression:

Stored size: 1.28 KB

Contents

module EventGroupsHelper
  def event_group_scoped_link(event_group, scope)
    new_filter  = {:whoops_filter => event_group_filter.to_query_document.merge(scope => event_group.send(scope))}
    link_to(event_group.send(scope), whoops_event_groups_path(new_filter))
  end
  
  # meant for consumption by options_from_collection_for_select
  def filter_options
    all_event_groups = Whoops::EventGroup.all
    return @filter_options if @filter_options

    @filter_options = Hash.new{|h, k| h[k] = []}
    
    @filter_options["service"] = Whoops::EventGroup.services.to_a
    
    all_event_groups.each do |event_group|
      mundane_fields = (Whoops::Filter.field_names & Whoops::EventGroup.field_names) - ["service", "message"]
      mundane_fields.each do |field_name|
        @filter_options[field_name] << event_group.send(field_name)
      end
    end
    
    # add the field name as an empty option
    @filter_options.keys.each do |field_name|
      @filter_options[field_name].compact!
      @filter_options[field_name].sort!{|a, b| a.first <=> b.first}.uniq! if @filter_options[field_name]
    end

    @filter_options
  end

  def filter_checked?(field_name, option)
    filtered_field = session[:event_group_filter].send(field_name)
    filtered_field && filtered_field.include?(option)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
whoops-0.2.1 app/helpers/event_groups_helper.rb
whoops-0.2 app/helpers/event_groups_helper.rb