mirror of
https://github.com/discourse/discourse.git
synced 2025-05-25 00:32:52 +08:00
REFACTOR: Move the multisite middleware to the front
Both request tracking and message bus rely on multisite before the middleware has run which is not ideal.
This commit is contained in:
@ -51,14 +51,6 @@ class Middleware::RequestTracker
|
||||
@app = app
|
||||
end
|
||||
|
||||
def self.log_request_on_site(data, host)
|
||||
RailsMultisite::ConnectionManagement.with_hostname(host) do
|
||||
unless Discourse.pg_readonly_mode?
|
||||
log_request(data)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def self.log_request(data)
|
||||
status = data[:status]
|
||||
track_view = data[:track_view]
|
||||
@ -135,7 +127,6 @@ class Middleware::RequestTracker
|
||||
|
||||
# we got to skip this on error ... its just logging
|
||||
data = self.class.get_data(env, result, info) rescue nil
|
||||
host = RailsMultisite::ConnectionManagement.host(env)
|
||||
|
||||
if data
|
||||
if result && (headers = result[1])
|
||||
@ -146,7 +137,7 @@ class Middleware::RequestTracker
|
||||
@@detailed_request_loggers.each { |logger| logger.call(env, data) }
|
||||
end
|
||||
|
||||
log_later(data, host)
|
||||
log_later(data)
|
||||
end
|
||||
|
||||
end
|
||||
@ -296,10 +287,11 @@ class Middleware::RequestTracker
|
||||
end
|
||||
end
|
||||
|
||||
def log_later(data, host)
|
||||
Scheduler::Defer.later("Track view", _db = nil) do
|
||||
self.class.log_request_on_site(data, host)
|
||||
def log_later(data)
|
||||
Scheduler::Defer.later("Track view") do
|
||||
unless Discourse.pg_readonly_mode?
|
||||
self.class.log_request(data)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
Reference in New Issue
Block a user