add new method that takes options hash, instead of using ugly method names.

fix for postgres select bug
upgrades in test_app Gemfile
This commit is contained in:
John McAliley 2011-06-03 11:54:58 -04:00
parent ae5ae23e1c
commit ff5e76a60b
5 changed files with 185 additions and 114 deletions

View File

@ -10,20 +10,30 @@ module Impressionist
true true
end end
def impressionist_count(options={})
options.reverse_merge!(:filter=>:request_hash, :start_date=>nil, :end_date=>Time.now)
imps = options[:start_date].blank? ? impressions : impressions.where("created_at>=? and created_at<=?",options[:start_date],options[:end_date])
if options[:filter]!=:all
imps = imps.select(options[:filter]).group(options[:filter])
end
imps.all.size
end
# OLD METHODS - DEPRECATE IN V0.5
def impression_count(start_date=nil,end_date=Time.now) def impression_count(start_date=nil,end_date=Time.now)
start_date.blank? ? impressions.all.size : impressions.where("created_at>=? and created_at<=?",start_date,end_date).all.size impressionist_count({:start_date=>start_date, :end_date=>end_date, :filter=>:all})
end end
def unique_impression_count(start_date=nil,end_date=Time.now) def unique_impression_count(start_date=nil,end_date=Time.now)
start_date.blank? ? impressions.group(:request_hash).all.size : impressions.where("created_at>=? and created_at<=?",start_date,end_date).group(:request_hash).all.size impressionist_count({:start_date=>start_date, :end_date=>end_date, :filter=> :request_hash})
end end
def unique_impression_count_ip(start_date=nil,end_date=Time.now) def unique_impression_count_ip(start_date=nil,end_date=Time.now)
start_date.blank? ? impressions.group(:ip_address).all.size : impressions.where("created_at>=? and created_at<=?",start_date,end_date).group(:ip_address).all.size impressionist_count({:start_date=>start_date, :end_date=>end_date, :filter=> :ip_address})
end end
def unique_impression_count_session(start_date=nil,end_date=Time.now) def unique_impression_count_session(start_date=nil,end_date=Time.now)
start_date.blank? ? impressions.group(:session_hash).all.size : impressions.where("created_at>=? and created_at<=?",start_date,end_date).group(:session_hash).all.size impressionist_count({:start_date=>start_date, :end_date=>end_date, :filter=> :session_hash})
end end
end end
end end

View File

@ -1,25 +1,23 @@
source 'http://rubygems.org' source 'http://rubygems.org'
gem 'rails', '3.0.4' gem 'rails', '3.1.0.rc1'
gem 'sqlite3-ruby', :require => 'sqlite3' gem 'sqlite3-ruby', :require => 'sqlite3'
gem 'impressionist', :path=>"#{File.dirname(__FILE__)}/../" gem 'impressionist', :path=>"#{File.dirname(__FILE__)}/../"
gem "pg"
if ENV['MY_BUNDLE_ENV'] == "dev" group :development do
group :development do gem 'ZenTest'
gem 'ZenTest' gem 'autotest'
gem 'autotest' gem 'systemu'
gem 'systemu' gem "rspec"
gem "rspec" gem "rspec-rails"
gem "rspec-rails" gem "mongrel", "1.2.0.pre2"
gem "mongrel", "1.2.0.pre2" gem 'capybara'
gem 'capybara' gem 'database_cleaner'
gem 'database_cleaner' gem 'cucumber-rails'
gem 'cucumber-rails' gem 'cucumber'
gem 'cucumber' gem 'spork'
gem 'spork' gem 'launchy'
gem 'launchy' gem 'autotest-notification'
gem 'autotest-notification' #gem 'ruby-debug19'
#gem 'ruby-debug19'
end
end end

View File

@ -1,85 +1,86 @@
PATH PATH
remote: /rails_plugins/mine/impressionist remote: /rails_plugins/mine/impressionist
specs: specs:
impressionist (0.2.5) impressionist (0.3.2)
GEM GEM
remote: http://rubygems.org/ remote: http://rubygems.org/
specs: specs:
ZenTest (4.4.2) ZenTest (4.5.0)
abstract (1.0.0) actionmailer (3.1.0.rc1)
actionmailer (3.0.4) actionpack (= 3.1.0.rc1)
actionpack (= 3.0.4) mail (~> 2.3.0)
mail (~> 2.2.15) actionpack (3.1.0.rc1)
actionpack (3.0.4) activemodel (= 3.1.0.rc1)
activemodel (= 3.0.4) activesupport (= 3.1.0.rc1)
activesupport (= 3.0.4) builder (~> 3.0.0)
builder (~> 2.1.2) erubis (~> 2.7.0)
erubis (~> 2.6.6) i18n (~> 0.6.0beta1)
i18n (~> 0.4) rack (~> 1.3.0.beta2)
rack (~> 1.2.1) rack-cache (~> 1.0.1)
rack-mount (~> 0.6.13) rack-mount (~> 0.8.1)
rack-test (~> 0.5.7) rack-test (~> 0.6.0)
tzinfo (~> 0.3.23) sprockets (~> 2.0.0.beta.5)
activemodel (3.0.4) tzinfo (~> 0.3.27)
activesupport (= 3.0.4) activemodel (3.1.0.rc1)
builder (~> 2.1.2) activesupport (= 3.1.0.rc1)
i18n (~> 0.4) bcrypt-ruby (~> 2.1.4)
activerecord (3.0.4) builder (~> 3.0.0)
activemodel (= 3.0.4) i18n (~> 0.6.0beta1)
activesupport (= 3.0.4) activerecord (3.1.0.rc1)
arel (~> 2.0.2) activemodel (= 3.1.0.rc1)
tzinfo (~> 0.3.23) activesupport (= 3.1.0.rc1)
activeresource (3.0.4) arel (~> 2.1.1)
activemodel (= 3.0.4) tzinfo (~> 0.3.27)
activesupport (= 3.0.4) activeresource (3.1.0.rc1)
activesupport (3.0.4) activemodel (= 3.1.0.rc1)
arel (2.0.8) activesupport (= 3.1.0.rc1)
activesupport (3.1.0.rc1)
multi_json (~> 1.0)
arel (2.1.1)
autotest (4.4.6) autotest (4.4.6)
ZenTest (>= 4.4.1) ZenTest (>= 4.4.1)
autotest-notification (2.3.1) autotest-notification (2.3.1)
autotest (~> 4.3) autotest (~> 4.3)
builder (2.1.2) bcrypt-ruby (2.1.4)
capybara (0.4.1.2) builder (3.0.0)
celerity (>= 0.7.9) capybara (1.0.0.beta1)
culerity (>= 0.2.4)
mime-types (>= 1.16) mime-types (>= 1.16)
nokogiri (>= 1.3.3) nokogiri (>= 1.3.3)
rack (>= 1.0.0) rack (>= 1.0.0)
rack-test (>= 0.5.4) rack-test (>= 0.5.4)
selenium-webdriver (>= 0.0.27) selenium-webdriver (>= 0.0.27)
xpath (~> 0.1.3) xpath (~> 0.1.4)
celerity (0.8.7) childprocess (0.1.9)
childprocess (0.1.6) ffi (~> 1.0.6)
ffi (~> 0.6.3)
configuration (1.2.0) configuration (1.2.0)
cucumber (0.10.0) cucumber (0.10.3)
builder (>= 2.1.2) builder (>= 2.1.2)
diff-lcs (~> 1.1.2) diff-lcs (>= 1.1.2)
gherkin (~> 2.3.2) gherkin (>= 2.3.8)
json (~> 1.4.6) json (>= 1.4.6)
term-ansicolor (~> 1.0.5) term-ansicolor (>= 1.0.5)
cucumber-rails (0.3.2) cucumber-rails (0.5.1)
cucumber (>= 0.8.0) capybara (>= 1.0.0.beta1)
culerity (0.2.15) cucumber (>= 0.10.3)
nokogiri (>= 1.4.4)
rack-test (>= 0.5.7)
daemons (1.0.10) daemons (1.0.10)
database_cleaner (0.6.3) database_cleaner (0.6.7)
diff-lcs (1.1.2) diff-lcs (1.1.2)
erubis (2.6.6) erubis (2.7.0)
abstract (>= 1.0.0) ffi (1.0.9)
ffi (0.6.3)
rake (>= 0.8.7)
gem_plugin (0.2.3) gem_plugin (0.2.3)
gherkin (2.3.3) gherkin (2.3.10)
json (~> 1.4.6) json (>= 1.4.6)
i18n (0.5.0) hike (1.0.0)
json (1.4.6) i18n (0.6.0)
json (1.5.1)
json_pure (1.5.1) json_pure (1.5.1)
launchy (0.3.7) launchy (0.4.0)
configuration (>= 0.0.5) configuration (>= 0.0.5)
rake (>= 0.8.1) rake (>= 0.8.1)
mail (2.2.15) mail (2.3.0)
activesupport (>= 2.3.6)
i18n (>= 0.4.0) i18n (>= 0.4.0)
mime-types (~> 1.16) mime-types (~> 1.16)
treetop (~> 1.4.8) treetop (~> 1.4.8)
@ -87,57 +88,69 @@ GEM
mongrel (1.2.0.pre2) mongrel (1.2.0.pre2)
daemons (~> 1.0.10) daemons (~> 1.0.10)
gem_plugin (~> 0.2.3) gem_plugin (~> 0.2.3)
multi_json (1.0.3)
nokogiri (1.4.4) nokogiri (1.4.4)
pg (0.11.0)
polyglot (0.3.1) polyglot (0.3.1)
rack (1.2.1) rack (1.3.0)
rack-mount (0.6.13) rack-cache (1.0.2)
rack (>= 0.4)
rack-mount (0.8.1)
rack (>= 1.0.0) rack (>= 1.0.0)
rack-test (0.5.7) rack-ssl (1.3.2)
rack
rack-test (0.6.0)
rack (>= 1.0) rack (>= 1.0)
rails (3.0.4) rails (3.1.0.rc1)
actionmailer (= 3.0.4) actionmailer (= 3.1.0.rc1)
actionpack (= 3.0.4) actionpack (= 3.1.0.rc1)
activerecord (= 3.0.4) activerecord (= 3.1.0.rc1)
activeresource (= 3.0.4) activeresource (= 3.1.0.rc1)
activesupport (= 3.0.4) activesupport (= 3.1.0.rc1)
bundler (~> 1.0) bundler (~> 1.0)
railties (= 3.0.4) railties (= 3.1.0.rc1)
railties (3.0.4) railties (3.1.0.rc1)
actionpack (= 3.0.4) actionpack (= 3.1.0.rc1)
activesupport (= 3.0.4) activesupport (= 3.1.0.rc1)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7) rake (>= 0.8.7)
thor (~> 0.14.4) thor (~> 0.14.6)
rake (0.8.7) rake (0.9.1)
rspec (2.5.0) rspec (2.6.0)
rspec-core (~> 2.5.0) rspec-core (~> 2.6.0)
rspec-expectations (~> 2.5.0) rspec-expectations (~> 2.6.0)
rspec-mocks (~> 2.5.0) rspec-mocks (~> 2.6.0)
rspec-core (2.5.1) rspec-core (2.6.3)
rspec-expectations (2.5.0) rspec-expectations (2.6.0)
diff-lcs (~> 1.1.2) diff-lcs (~> 1.1.2)
rspec-mocks (2.5.0) rspec-mocks (2.6.0)
rspec-rails (2.5.0) rspec-rails (2.6.1)
actionpack (~> 3.0) actionpack (~> 3.0)
activesupport (~> 3.0) activesupport (~> 3.0)
railties (~> 3.0) railties (~> 3.0)
rspec (~> 2.5.0) rspec (~> 2.6.0)
rubyzip (0.9.4) rubyzip (0.9.4)
selenium-webdriver (0.1.2) selenium-webdriver (0.2.1)
childprocess (~> 0.1.5) childprocess (>= 0.1.7)
ffi (~> 0.6.3) ffi (>= 1.0.7)
json_pure json_pure
rubyzip rubyzip
spork (0.8.4) spork (0.8.5)
sprockets (2.0.0.beta.9)
hike (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sqlite3 (1.3.3) sqlite3 (1.3.3)
sqlite3-ruby (1.3.3) sqlite3-ruby (1.3.3)
sqlite3 (>= 1.3.3) sqlite3 (>= 1.3.3)
systemu (1.2.0) systemu (2.2.0)
term-ansicolor (1.0.5) term-ansicolor (1.0.5)
thor (0.14.6) thor (0.14.6)
tilt (1.3.2)
treetop (1.4.9) treetop (1.4.9)
polyglot (>= 0.3.1) polyglot (>= 0.3.1)
tzinfo (0.3.24) tzinfo (0.3.27)
xpath (0.1.3) xpath (0.1.4)
nokogiri (~> 1.3) nokogiri (~> 1.3)
PLATFORMS PLATFORMS
@ -154,7 +167,8 @@ DEPENDENCIES
impressionist! impressionist!
launchy launchy
mongrel (= 1.2.0.pre2) mongrel (= 1.2.0.pre2)
rails (= 3.0.4) pg
rails (= 3.1.0.rc1)
rspec rspec
rspec-rails rspec-rails
spork spork

View File

@ -9,12 +9,26 @@ development:
# Warning: The database defined as "test" will be erased and # Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake". # re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production. # Do not set this db to the same as development or production.
test: &test #test: &test
# adapter: sqlite3
# database: db/test.sqlite3
# pool: 5
# timeout: 5000
test:
adapter: sqlite3 adapter: sqlite3
database: db/test.sqlite3 database: db/test.sqlite3
pool: 5 pool: 5
timeout: 5000 timeout: 5000
pg_test:
adapter: postgresql
database: impressionist_test
username: johnmcaliley
password:
host: localhost
encoding: UTF8
production: production:
adapter: sqlite3 adapter: sqlite3
database: db/production.sqlite3 database: db/production.sqlite3

View File

@ -0,0 +1,35 @@
TestApp::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suite and is wiped
# and recreated between test runs. Don't rely on the data there!
config.cache_classes = true
# Log error messages when you accidentally call methods on nil.
config.whiny_nils = true
# Show full error reports and disable caching
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
# Raise exceptions instead of rendering exception templates
config.action_dispatch.show_exceptions = false
# Disable request forgery protection in test environment
config.action_controller.allow_forgery_protection = false
# Tell Action Mailer not to deliver emails to the real world.
# The :test delivery method accumulates sent emails in the
# ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test
# Use SQL instead of Active Record's schema dumper when creating the test database.
# This is necessary if your schema can't be completely dumped by the schema dumper,
# like if you have constraints or database-specific column types
# config.active_record.schema_format = :sql
# Print deprecation notices to the stderr
config.active_support.deprecation = :stderr
end