don't count spider traffic towards traffic counter

This commit is contained in:
joshua stein 2012-12-16 18:46:38 -06:00
parent a9e169175b
commit c6c4169ae3

View file

@ -16,6 +16,10 @@ class ApplicationController < ActionController::Base
def increase_traffic_counter
@traffic = 1.0
if user_is_spider?
return true
end
Keystore.transaction do
date = (Keystore.value_for("traffic:date") || Time.now.to_i)
traffic = (Keystore.incremented_value_for("traffic:hits", 0).
@ -50,4 +54,8 @@ class ApplicationController < ActionController::Base
return false
end
end
def user_is_spider?
!!request.env["HTTP_USER_AGENT"].to_s.match(/Googlebot/)
end
end