Sha256: bd96fdbf257d41b534c8f5bcd6f618490e67e6f635f191f53745c2ac4bc3bd82

Contents?: true

Size: 901 Bytes

Versions: 2

Compression:

Stored size: 901 Bytes

Contents

module Appstats
  class ActionContextKey < ActiveRecord::Base
    set_table_name "appstats_action_context_keys"
    establish_connection "appstats_#{Rails.env}" if configurations.keys.include?("appstats_#{Rails.env}")
    
    attr_accessible :action_name, :context_key, :status
  
    def self.update_action_context_keys
      sql = "select action,context_key,count(*) as num
      from appstats_entries 
      inner join appstats_contexts on appstats_contexts.appstats_entry_id = appstats_entries.id
      where (action,context_key) not in (select action_name, context_key from appstats_action_context_keys)
      group by action,context_key"
      count = 0
      ActiveRecord::Base.connection.execute(sql).each do |row| 
        Appstats::ActionContextKey.create(:action_name => row[0], :context_key => row[1], :status => 'derived')
        count += 1
      end
      count
    end
    
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
appstats-0.22.2 lib/appstats/action_context_key.rb
appstats-0.22.1 lib/appstats/action_context_key.rb