Class: Appstats::ActionContextKey

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/appstats/action_context_key.rb

Class Method Summary collapse

Class Method Details

.update_action_context_keysObject



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/appstats/action_context_key.rb', line 9

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
  Appstats.connection.execute(sql).each do |row| 
    Appstats::ActionContextKey.create(:action_name => row[0], :context_key => row[1], :status => 'derived')
    count += 1
  end
  count
end