From 1a8d6c5a947daca63c2c66a92991b2b8e02460f1 Mon Sep 17 00:00:00 2001 From: Cory Schires Date: Sun, 27 Nov 2011 13:51:51 -0600 Subject: [PATCH] Updated readme. --- README.md | 14 +++---- test_app/Gemfile.lock | 2 +- ...20111127195013_create_impressions_table.rb | 37 +++++++++++++++++++ 3 files changed, 45 insertions(+), 8 deletions(-) create mode 100644 test_app/db/migrate/20111127195013_create_impressions_table.rb diff --git a/README.md b/README.md index 22333b9..76d3542 100644 --- a/README.md +++ b/README.md @@ -125,18 +125,18 @@ What if I only want to record unique impressions? ------------------------------------------------- Maybe you only care about unique impressions and would like to eliminate unnecessary database calls. You can specify conditions for recording impressions in your controller: - # only record impression if the request has a unique combination of type, id, and session - impressionist :unique => [:impressionable_type, :impressionable_id, :session_hash] + # only record impression if the request has a unique combination of type, id, and session + impressionist :unique => [:impressionable_type, :impressionable_id, :session_hash] - # only record impression if the request has a unique combination of controller, action, and session - impressionist :unique => [:controller_name, :action_name, :session_hash] + # only record impression if the request has a unique combination of controller, action, and session + impressionist :unique => [:controller_name, :action_name, :session_hash] - # only record impression if session is unique - impressionist :unique => [:session_hash] + # only record impression if session is unique + impressionist :unique => [:session_hash] Or you can use the `impressionist` method directly: - impressionist(impressionable, "some message", :unique => [:session_hash]) + impressionist(impressionable, "some message", :unique => [:session_hash]) Development Roadmap diff --git a/test_app/Gemfile.lock b/test_app/Gemfile.lock index 5c4af6e..130489c 100644 --- a/test_app/Gemfile.lock +++ b/test_app/Gemfile.lock @@ -1,5 +1,5 @@ PATH - remote: /Users/coryschires/Desktop/impressionist + remote: /Users/coryschires/Desktop/work/applications/impressionist specs: impressionist (0.4.0) diff --git a/test_app/db/migrate/20111127195013_create_impressions_table.rb b/test_app/db/migrate/20111127195013_create_impressions_table.rb new file mode 100644 index 0000000..22b6a90 --- /dev/null +++ b/test_app/db/migrate/20111127195013_create_impressions_table.rb @@ -0,0 +1,37 @@ +class CreateImpressionsTable < ActiveRecord::Migration + def self.up + create_table :impressions, :force => true do |t| + t.string :impressionable_type + t.integer :impressionable_id + t.integer :user_id + t.string :controller_name + t.string :action_name + t.string :view_name + t.string :request_hash + t.string :session_hash + t.string :ip_address + t.string :message + t.string :referrer + t.timestamps + end + add_index :impressions, [:impressionable_type, :impressionable_id, :request_hash], :name => "poly_request_index", :unique => false + add_index :impressions, [:impressionable_type, :impressionable_id, :ip_address], :name => "poly_ip_index", :unique => false + add_index :impressions, [:impressionable_type, :impressionable_id, :session_hash], :name => "poly_session_index", :unique => false + add_index :impressions, [:controller_name,:action_name,:request_hash], :name => "controlleraction_request_index", :unique => false + add_index :impressions, [:controller_name,:action_name,:ip_address], :name => "controlleraction_ip_index", :unique => false + add_index :impressions, [:controller_name,:action_name,:session_hash], :name => "controlleraction_session_index", :unique => false + add_index :impressions, :user_id + end + + def self.down + remove_index :impressions, :name => :poly_request_index + remove_index :impressions, :name => :poly_ip_index + remove_index :impressions, :name => :poly_session_index + remove_index :impressions, :name => :controlleraction_request_index + remove_index :impressions, :name => :controlleraction_ip_index + remove_index :impressions, :name => :controlleraction_session_index + remove_index :impressions, :user_id + + drop_table :impressions + end +end \ No newline at end of file