Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasc committed Aug 14, 2014
1 parent 3675295 commit ff42da9
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ Followed by an aggregation. For example on access count:
Mongoid::TrafficLog.daily(Date.today).for_scope('/pages/123').aggregate_on(:access_count)
```

The scope query accepts regular expressions, which allows for aggregations on specific parts of your site. For exmaple should you want to query for all pages that have path beginning with '/blog':
The scope query accepts regular expressions, which allows for aggregations on specific parts of your site. For example should you want to query for all pages that have path beginning with '/blog':

```Ruby
Mongoid::TrafficLog.monthly(8, 2014).for_scope(/\A\/blog/).aggregate_on(:country)
Expand Down
1 change: 1 addition & 0 deletions lib/mongoid_traffic/log.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class Log

scope :yearly, -> year { self.for_dates(Date.parse("01/01/#{year}"), Date.parse("01/01/#{year}").at_end_of_year) }
scope :monthly, -> month, year { self.for_dates(Date.parse("01/#{month}/#{year}"), Date.parse("01/#{month}/#{year}").at_end_of_month) }
scope :weekly, -> week, year { self.for_dates(Date.commercial(year, week), Date.commercial(year, week).at_end_of_week) }
scope :daily, -> date { self.for_dates(date, date) }

scope :for_scope, -> scope { where(scope: scope) }
Expand Down
3 changes: 1 addition & 2 deletions test/mongoid_traffic/logger_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ module MongoidTraffic
end

it 'logs for month' do
p Log.monthly(month, year).first
Log.monthly(month, year).count.must_equal 1
end
it 'logs for date' do
Expand Down Expand Up @@ -50,7 +49,7 @@ module MongoidTraffic
describe 'when referer a bot' do
let(:referer) { 'Googlebot/Test ( http://www.googlebot.com/bot.html)' }
it 'does not create log' do
Log.unscoped.wont_be :exists?
Log.exists?.must_equal false
end
end
end
Expand Down

0 comments on commit ff42da9

Please sign in to comment.