improve metrics gathered using in our traffic section

this also pulls out the middleware into its own home and inserts in front
This commit is contained in:
Sam
2015-02-05 16:08:52 +11:00
parent ebc2ad7c81
commit 08b790b3c2
14 changed files with 188 additions and 104 deletions

View File

@ -114,29 +114,6 @@ module Middleware
@app = app
end
def self.log_request_on_site(env, helper=nil)
host = RailsMultisite::ConnectionManagement.host(env)
RailsMultisite::ConnectionManagement.with_hostname(host) do
log_request(env,helper)
end
end
def self.log_request(env,helper=nil)
helper ||= Helper.new(env)
type =
if helper.is_crawler?
:crawler
elsif helper.has_auth_cookie?
:logged_in
else
:anon
end
ApplicationRequest.increment!(type)
end
def call(env)
helper = Helper.new(env)
@ -146,10 +123,6 @@ module Middleware
@app.call(env)
end
ensure
Scheduler::Defer.later "Track view" do
self.class.log_request_on_site(env,helper)
end
end
end