Change impression count to exclude when :referrer is nil

This commit is contained in:
Christophe Vilayphiou 2012-05-18 14:13:11 +08:00
parent d9c12ea5a4
commit 7c6b807170
4 changed files with 11 additions and 9 deletions

View File

@ -30,7 +30,7 @@ class Admin::DashboardsController < ApplicationController
module_app_class = module_app.classify.constantize
objects = module_app_class.order_by(:updated_at, :desc).limit(10)
objects.each do |object|
a.merge!(object => object.updated_at)
a.merge!(object => object.updated_at) unless (object.archived rescue nil)
end
end
sorted_objects = a.sort {|a,b| b[1]<=>a[1]}
@ -43,7 +43,7 @@ class Admin::DashboardsController < ApplicationController
module_app_class = module_app.classify.constantize
objects = module_app_class.order_by(:view_count, :desc).limit(10)
objects.each do |object|
a.merge!(object => object.view_count) if object.view_count > 0
a.merge!(object => object.view_count) if object.view_count > 0 && (!object.archived rescue true)
end
end
sorted_objects = a.sort {|a,b| b[1]<=>a[1]}

View File

@ -181,7 +181,7 @@ module ApplicationHelper
end
def display_visitors(options={})
Impression.where(options).distinct(:session_hash).count
Impression.where(options).and(:referrer.ne => nil).distinct(:session_hash).count
end
def display_visitors_today

View File

@ -8,7 +8,7 @@ defaults: &defaults
development:
<<: *defaults
database: prototype_r4_ldap0229
database: bob
test:
<<: *defaults
@ -22,4 +22,4 @@ production:
# password: <%= ENV['MONGOID_PASSWORD'] %>
# database: <%= ENV['MONGOID_DATABASE'] %>
<<: *defaults
database: prototype_r4_ldap0229
database: prototype_r4_development

View File

@ -27,6 +27,7 @@ class Impression
private
def update_impressions_counter_cache
if self.referrer
impressionable_class = self.impressionable_type.constantize
if impressionable_class.impressionist_counter_cache_options
@ -34,4 +35,5 @@ class Impression
resouce.try(:update_impressionist_counter_cache)
end
end
end
end