impressionist 0.3.2 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.rdoc CHANGED
@@ -1,3 +1,10 @@
1
+ == 0.4.0 (2011-06-03)
2
+ * Fix postgres bug
3
+ * New impression count method that accepts options for filter, start_date and end_date
4
+ * Add referrer to Impression model. YOU MUST RUN THE UPGRADE MIGRATION IF YOU ARE UPGRADING FROM 0.3.0
5
+ * UPGRADE MIGRATION = impressionist/upgrade_migrations/version_0_4_0.rb
6
+ * NOTE IF YOU ARE UPGRADING FROM 0.2.5 OR BELOW, YOU MUST RUN BOTH UPGRADE MIGRATIONS
7
+
1
8
  == 0.3.0 (2011-03-06)
2
9
  * added session_hash to impression model
3
10
  * migration template updated to add session_hash
data/Gemfile CHANGED
@@ -7,21 +7,20 @@ group :development do
7
7
  gem "rcov", ">= 0"
8
8
  end
9
9
 
10
- if ENV['MY_BUNDLE_ENV'] == "dev"
11
- group :development do
12
- gem 'ZenTest'
13
- gem 'autotest'
14
- gem 'systemu'
15
- gem "rspec"
16
- gem "rspec-rails"
17
- gem "mongrel", "1.2.0.pre2"
18
- gem 'capybara'
19
- gem 'database_cleaner'
20
- gem 'cucumber-rails'
21
- gem 'cucumber'
22
- gem 'spork'
23
- gem 'launchy'
24
- gem 'autotest-notification'
25
- gem 'httpclient'
26
- end
10
+ group :test do
11
+ gem 'ZenTest'
12
+ gem 'autotest'
13
+ gem 'systemu'
14
+ gem "rspec"
15
+ gem "rspec-rails"
16
+ gem "mongrel", "1.2.0.pre2"
17
+ gem 'capybara'
18
+ gem 'database_cleaner'
19
+ gem 'cucumber-rails'
20
+ gem 'cucumber'
21
+ gem 'spork'
22
+ gem 'launchy'
23
+ gem 'autotest-notification'
24
+ gem 'httpclient'
27
25
  end
26
+
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- ![Impressionist Logo](https://github.com/cowboycoded/impressionist/raw/master/logo.png)
1
+ ![Impressionist Logo](https://github.com/charlotte-ruby/impressionist/raw/master/logo.png)
2
2
 
3
3
  impressionist
4
4
  =============
@@ -53,6 +53,7 @@ The following fields are provided in the migration:
53
53
  t.string "request_hash" # unique ID per request, in case you want to log multiple impressions and group them
54
54
  t.string "session_hash" # logs the rails session
55
55
  t.string "ip_address" # request.remote_ip
56
+ t.string "referrer" # request.referer
56
57
  t.string "message" # custom message you can add
57
58
  t.datetime "created_at" # I am not sure what this is.... Any clue?
58
59
  t.datetime "updated_at" # never seen this one before either.... Your guess is as good as mine??
@@ -86,24 +87,22 @@ Usage
86
87
  end
87
88
 
88
89
  5. Get unique impression count from a model. This groups impressions by request_hash, so if you logged multiple impressions per request, it will only count them one time. This unique impression count will not filter out unique users, only unique requests
89
- @widget.unique_impression_count
90
- @widget.unique_impression_count("2011-01-01","2011-01-02") # start date, end date
91
- @widget.unique_impression_count("2011-01-01") #specify start date only, end date = now
90
+
91
+ @widget.impressionist_count
92
+ @widget.impressionist_count(:start_date=>"2011-01-01",:end_date=>"2011-01-05")
93
+ @widget.impressionist_count(:start_date=>"2011-01-01") #specify start date only, end date = now
92
94
 
93
95
  6. Get the unique impression count from a model filtered by IP address. This in turn will give you impressions with unique request_hash, since rows with the same request_hash will have the same IP address.
94
- @widget.unique_impression_count_ip
95
- @widget.unique_impression_count_ip("2011-01-01","2011-01-02") # start date, end date
96
- @widget.unique_impression_count_ip("2011-01-01") #specify start date only, end date = now
97
96
 
97
+ @widget.impressionist_count(:filter=>:ip_address)
98
+
98
99
  7. Get the unique impression count from a model filtered by session hash. Same as #6 regarding request hash. This may be more desirable than filtering by IP address depending on your situation, since filtering by IP may ignore visitors that use the same IP. The downside to this filtering is that a user could clear session data in their browser and skew the results.
99
- @widget.unique_impression_count_session
100
- @widget.unique_impression_count_session("2011-01-01","2011-01-02") # start date, end date
101
- @widget.unique_impression_count_session("2011-01-01") #specify start date only, end date = now
100
+
101
+ @widget.impressionist_count(:filter=>:session_hash)
102
102
 
103
103
  8. Get total impression count. This may return more than 1 impression per http request, depending on how you are logging impressions
104
- @widget.impression_count
105
- @widget.impression_count("2011-01-01","2011-01-02") # start date, end date
106
- @widget.impression_count("2011-01-01") #specify start date only, end date = now
104
+
105
+ @widget.impressionist_count(:filter=>:all)
107
106
 
108
107
  Logging impressions for authenticated users happens automatically. If you have a current_user helper or use @current_user in your before_filter to set your authenticated user, current_user.id will be written to the user_id field in the impressions table.
109
108
 
@@ -126,8 +125,4 @@ Contributing to impressionist
126
125
  * If adding engine controller or view functionality, use HAML and Inherited Resources.
127
126
  * All testing is done inside a small Rails app (test_app). You will find specs within this app.
128
127
 
129
- Copyright
130
- ---------
131
- Copyright (c) 2011 cowboycoded. See LICENSE.txt for
132
- further details.
133
-
128
+ Copyright (c) 2011 John McAliley. See LICENSE.txt for further details.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.2
1
+ 0.4.0
@@ -21,7 +21,8 @@ module ImpressionistController
21
21
  :ip_address=> request.remote_ip,
22
22
  :user_id=> user_id,
23
23
  :controller_name=>controller_name,
24
- :action_name=> action_name)
24
+ :action_name=> action_name,
25
+ :referrer=>request.referer)
25
26
  else
26
27
  raise "#{obj.class.to_s} is not impressionable!"
27
28
  end
@@ -43,7 +44,8 @@ module ImpressionistController
43
44
  :session_hash=> request.session_options[:id],
44
45
  :ip_address=> request.remote_ip,
45
46
  :impressionable_type=> controller_name.singularize.camelize,
46
- :impressionable_id=> params[:id])
47
+ :impressionable_id=> params[:id],
48
+ :referrer=>request.referer)
47
49
  end
48
50
  end
49
51
  end
@@ -10,20 +10,30 @@ module Impressionist
10
10
  true
11
11
  end
12
12
 
13
+ def impressionist_count(options={})
14
+ options.reverse_merge!(:filter=>:request_hash, :start_date=>nil, :end_date=>Time.now)
15
+ imps = options[:start_date].blank? ? impressions : impressions.where("created_at>=? and created_at<=?",options[:start_date],options[:end_date])
16
+ if options[:filter]!=:all
17
+ imps = imps.select(options[:filter]).group(options[:filter])
18
+ end
19
+ imps.all.size
20
+ end
21
+
22
+ # OLD METHODS - DEPRECATE IN V0.5
13
23
  def impression_count(start_date=nil,end_date=Time.now)
14
- start_date.blank? ? impressions.all.size : impressions.where("created_at>=? and created_at<=?",start_date,end_date).all.size
24
+ impressionist_count({:start_date=>start_date, :end_date=>end_date, :filter=>:all})
15
25
  end
16
26
 
17
27
  def unique_impression_count(start_date=nil,end_date=Time.now)
18
- 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
28
+ impressionist_count({:start_date=>start_date, :end_date=>end_date, :filter=> :request_hash})
19
29
  end
20
30
 
21
31
  def unique_impression_count_ip(start_date=nil,end_date=Time.now)
22
- 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
32
+ impressionist_count({:start_date=>start_date, :end_date=>end_date, :filter=> :ip_address})
23
33
  end
24
34
 
25
35
  def unique_impression_count_session(start_date=nil,end_date=Time.now)
26
- 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
36
+ impressionist_count({:start_date=>start_date, :end_date=>end_date, :filter=> :session_hash})
27
37
  end
28
38
  end
29
39
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{impressionist}
8
- s.version = "0.3.2"
8
+ s.version = "0.4.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["cowboycoded"]
12
- s.date = %q{2011-03-21}
12
+ s.date = %q{2011-06-03}
13
13
  s.description = %q{Log impressions from controller actions or from a model}
14
14
  s.email = %q{john.mcaliley@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -36,7 +36,8 @@ Gem::Specification.new do |s|
36
36
  "lib/impressionist/engine.rb",
37
37
  "lib/impressionist/railties/tasks.rake",
38
38
  "logo.png",
39
- "upgrade_migrations/version_0_3_0.rb"
39
+ "upgrade_migrations/version_0_3_0.rb",
40
+ "upgrade_migrations/version_0_4_0.rb"
40
41
  ]
41
42
  s.homepage = %q{http://github.com/cowboycoded/impressionist}
42
43
  s.licenses = ["MIT"]
@@ -53,59 +54,17 @@ Gem::Specification.new do |s|
53
54
  s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
54
55
  s.add_development_dependency(%q<jeweler>, ["~> 1.5.1"])
55
56
  s.add_development_dependency(%q<rcov>, [">= 0"])
56
- s.add_development_dependency(%q<ZenTest>, [">= 0"])
57
- s.add_development_dependency(%q<autotest>, [">= 0"])
58
- s.add_development_dependency(%q<systemu>, [">= 0"])
59
- s.add_development_dependency(%q<rspec>, [">= 0"])
60
- s.add_development_dependency(%q<rspec-rails>, [">= 0"])
61
- s.add_development_dependency(%q<mongrel>, ["= 1.2.0.pre2"])
62
- s.add_development_dependency(%q<capybara>, [">= 0"])
63
- s.add_development_dependency(%q<database_cleaner>, [">= 0"])
64
- s.add_development_dependency(%q<cucumber-rails>, [">= 0"])
65
- s.add_development_dependency(%q<cucumber>, [">= 0"])
66
- s.add_development_dependency(%q<spork>, [">= 0"])
67
- s.add_development_dependency(%q<launchy>, [">= 0"])
68
- s.add_development_dependency(%q<autotest-notification>, [">= 0"])
69
- s.add_development_dependency(%q<httpclient>, [">= 0"])
70
57
  else
71
58
  s.add_dependency(%q<shoulda>, [">= 0"])
72
59
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
73
60
  s.add_dependency(%q<jeweler>, ["~> 1.5.1"])
74
61
  s.add_dependency(%q<rcov>, [">= 0"])
75
- s.add_dependency(%q<ZenTest>, [">= 0"])
76
- s.add_dependency(%q<autotest>, [">= 0"])
77
- s.add_dependency(%q<systemu>, [">= 0"])
78
- s.add_dependency(%q<rspec>, [">= 0"])
79
- s.add_dependency(%q<rspec-rails>, [">= 0"])
80
- s.add_dependency(%q<mongrel>, ["= 1.2.0.pre2"])
81
- s.add_dependency(%q<capybara>, [">= 0"])
82
- s.add_dependency(%q<database_cleaner>, [">= 0"])
83
- s.add_dependency(%q<cucumber-rails>, [">= 0"])
84
- s.add_dependency(%q<cucumber>, [">= 0"])
85
- s.add_dependency(%q<spork>, [">= 0"])
86
- s.add_dependency(%q<launchy>, [">= 0"])
87
- s.add_dependency(%q<autotest-notification>, [">= 0"])
88
- s.add_dependency(%q<httpclient>, [">= 0"])
89
62
  end
90
63
  else
91
64
  s.add_dependency(%q<shoulda>, [">= 0"])
92
65
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
93
66
  s.add_dependency(%q<jeweler>, ["~> 1.5.1"])
94
67
  s.add_dependency(%q<rcov>, [">= 0"])
95
- s.add_dependency(%q<ZenTest>, [">= 0"])
96
- s.add_dependency(%q<autotest>, [">= 0"])
97
- s.add_dependency(%q<systemu>, [">= 0"])
98
- s.add_dependency(%q<rspec>, [">= 0"])
99
- s.add_dependency(%q<rspec-rails>, [">= 0"])
100
- s.add_dependency(%q<mongrel>, ["= 1.2.0.pre2"])
101
- s.add_dependency(%q<capybara>, [">= 0"])
102
- s.add_dependency(%q<database_cleaner>, [">= 0"])
103
- s.add_dependency(%q<cucumber-rails>, [">= 0"])
104
- s.add_dependency(%q<cucumber>, [">= 0"])
105
- s.add_dependency(%q<spork>, [">= 0"])
106
- s.add_dependency(%q<launchy>, [">= 0"])
107
- s.add_dependency(%q<autotest-notification>, [">= 0"])
108
- s.add_dependency(%q<httpclient>, [">= 0"])
109
68
  end
110
69
  end
111
70
 
@@ -11,6 +11,7 @@ class CreateImpressionsTable < ActiveRecord::Migration
11
11
  t.string :session_hash
12
12
  t.string :ip_address
13
13
  t.string :message
14
+ t.string :referrer
14
15
  t.timestamps
15
16
  end
16
17
  add_index :impressions, [:impressionable_type, :impressionable_id, :request_hash], :name => "poly_request_index", :unique => false
@@ -0,0 +1,9 @@
1
+ class Version04UpdateImpressionsTable < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :impressions, :referrer, :string
4
+ end
5
+
6
+ def self.down
7
+ remove_column :impressions, :referrer
8
+ end
9
+ end
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 3
8
- - 2
9
- version: 0.3.2
7
+ - 4
8
+ - 0
9
+ version: 0.4.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - cowboycoded
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-03-21 00:00:00 -04:00
17
+ date: 2011-06-03 00:00:00 -04:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -73,191 +73,6 @@ dependencies:
73
73
  type: :development
74
74
  prerelease: false
75
75
  version_requirements: *id004
76
- - !ruby/object:Gem::Dependency
77
- name: ZenTest
78
- requirement: &id005 !ruby/object:Gem::Requirement
79
- none: false
80
- requirements:
81
- - - ">="
82
- - !ruby/object:Gem::Version
83
- segments:
84
- - 0
85
- version: "0"
86
- type: :development
87
- prerelease: false
88
- version_requirements: *id005
89
- - !ruby/object:Gem::Dependency
90
- name: autotest
91
- requirement: &id006 !ruby/object:Gem::Requirement
92
- none: false
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- segments:
97
- - 0
98
- version: "0"
99
- type: :development
100
- prerelease: false
101
- version_requirements: *id006
102
- - !ruby/object:Gem::Dependency
103
- name: systemu
104
- requirement: &id007 !ruby/object:Gem::Requirement
105
- none: false
106
- requirements:
107
- - - ">="
108
- - !ruby/object:Gem::Version
109
- segments:
110
- - 0
111
- version: "0"
112
- type: :development
113
- prerelease: false
114
- version_requirements: *id007
115
- - !ruby/object:Gem::Dependency
116
- name: rspec
117
- requirement: &id008 !ruby/object:Gem::Requirement
118
- none: false
119
- requirements:
120
- - - ">="
121
- - !ruby/object:Gem::Version
122
- segments:
123
- - 0
124
- version: "0"
125
- type: :development
126
- prerelease: false
127
- version_requirements: *id008
128
- - !ruby/object:Gem::Dependency
129
- name: rspec-rails
130
- requirement: &id009 !ruby/object:Gem::Requirement
131
- none: false
132
- requirements:
133
- - - ">="
134
- - !ruby/object:Gem::Version
135
- segments:
136
- - 0
137
- version: "0"
138
- type: :development
139
- prerelease: false
140
- version_requirements: *id009
141
- - !ruby/object:Gem::Dependency
142
- name: mongrel
143
- requirement: &id010 !ruby/object:Gem::Requirement
144
- none: false
145
- requirements:
146
- - - "="
147
- - !ruby/object:Gem::Version
148
- segments:
149
- - 1
150
- - 2
151
- - 0
152
- - pre2
153
- version: 1.2.0.pre2
154
- type: :development
155
- prerelease: false
156
- version_requirements: *id010
157
- - !ruby/object:Gem::Dependency
158
- name: capybara
159
- requirement: &id011 !ruby/object:Gem::Requirement
160
- none: false
161
- requirements:
162
- - - ">="
163
- - !ruby/object:Gem::Version
164
- segments:
165
- - 0
166
- version: "0"
167
- type: :development
168
- prerelease: false
169
- version_requirements: *id011
170
- - !ruby/object:Gem::Dependency
171
- name: database_cleaner
172
- requirement: &id012 !ruby/object:Gem::Requirement
173
- none: false
174
- requirements:
175
- - - ">="
176
- - !ruby/object:Gem::Version
177
- segments:
178
- - 0
179
- version: "0"
180
- type: :development
181
- prerelease: false
182
- version_requirements: *id012
183
- - !ruby/object:Gem::Dependency
184
- name: cucumber-rails
185
- requirement: &id013 !ruby/object:Gem::Requirement
186
- none: false
187
- requirements:
188
- - - ">="
189
- - !ruby/object:Gem::Version
190
- segments:
191
- - 0
192
- version: "0"
193
- type: :development
194
- prerelease: false
195
- version_requirements: *id013
196
- - !ruby/object:Gem::Dependency
197
- name: cucumber
198
- requirement: &id014 !ruby/object:Gem::Requirement
199
- none: false
200
- requirements:
201
- - - ">="
202
- - !ruby/object:Gem::Version
203
- segments:
204
- - 0
205
- version: "0"
206
- type: :development
207
- prerelease: false
208
- version_requirements: *id014
209
- - !ruby/object:Gem::Dependency
210
- name: spork
211
- requirement: &id015 !ruby/object:Gem::Requirement
212
- none: false
213
- requirements:
214
- - - ">="
215
- - !ruby/object:Gem::Version
216
- segments:
217
- - 0
218
- version: "0"
219
- type: :development
220
- prerelease: false
221
- version_requirements: *id015
222
- - !ruby/object:Gem::Dependency
223
- name: launchy
224
- requirement: &id016 !ruby/object:Gem::Requirement
225
- none: false
226
- requirements:
227
- - - ">="
228
- - !ruby/object:Gem::Version
229
- segments:
230
- - 0
231
- version: "0"
232
- type: :development
233
- prerelease: false
234
- version_requirements: *id016
235
- - !ruby/object:Gem::Dependency
236
- name: autotest-notification
237
- requirement: &id017 !ruby/object:Gem::Requirement
238
- none: false
239
- requirements:
240
- - - ">="
241
- - !ruby/object:Gem::Version
242
- segments:
243
- - 0
244
- version: "0"
245
- type: :development
246
- prerelease: false
247
- version_requirements: *id017
248
- - !ruby/object:Gem::Dependency
249
- name: httpclient
250
- requirement: &id018 !ruby/object:Gem::Requirement
251
- none: false
252
- requirements:
253
- - - ">="
254
- - !ruby/object:Gem::Version
255
- segments:
256
- - 0
257
- version: "0"
258
- type: :development
259
- prerelease: false
260
- version_requirements: *id018
261
76
  description: Log impressions from controller actions or from a model
262
77
  email: john.mcaliley@gmail.com
263
78
  executables: []
@@ -288,6 +103,7 @@ files:
288
103
  - lib/impressionist/railties/tasks.rake
289
104
  - logo.png
290
105
  - upgrade_migrations/version_0_3_0.rb
106
+ - upgrade_migrations/version_0_4_0.rb
291
107
  has_rdoc: true
292
108
  homepage: http://github.com/cowboycoded/impressionist
293
109
  licenses:
@@ -302,7 +118,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
302
118
  requirements:
303
119
  - - ">="
304
120
  - !ruby/object:Gem::Version
305
- hash: 916626274296505275
121
+ hash: -566691724227540930
306
122
  segments:
307
123
  - 0
308
124
  version: "0"