|
|
|
|
@ -30,14 +30,16 @@ class OnlineMiddleware(object):
|
|
|
|
|
http_user_agent = request.META.get('HTTP_USER_AGENT', [])
|
|
|
|
|
if 'Spider' in http_user_agent or 'spider' in http_user_agent:
|
|
|
|
|
return response
|
|
|
|
|
try:
|
|
|
|
|
cast_time = time.time() - start_time
|
|
|
|
|
if ELASTICSEARCH_ENABLED:
|
|
|
|
|
time_taken = round((cast_time) * 1000, 2)
|
|
|
|
|
url = request.path
|
|
|
|
|
from django.utils import timezone
|
|
|
|
|
|
|
|
|
|
cast_time = time.time() - start_time
|
|
|
|
|
if ELASTICSEARCH_ENABLED:
|
|
|
|
|
time_taken = round((cast_time) * 1000, 2)
|
|
|
|
|
url = request.path
|
|
|
|
|
from django.utils import timezone
|
|
|
|
|
|
|
|
|
|
ElaspedTimeDocumentManager.create(url=url, time_taken=time_taken, log_datetime=timezone.now(),
|
|
|
|
|
type='blog', useragent=http_user_agent)
|
|
|
|
|
response.content = response.content.replace(b'<!!LOAD_TIMES!!>', str.encode(str(cast_time)[:5]))
|
|
|
|
|
ElaspedTimeDocumentManager.create(url=url, time_taken=time_taken, log_datetime=timezone.now(),
|
|
|
|
|
type='blog', useragent=http_user_agent)
|
|
|
|
|
response.content = response.content.replace(b'<!!LOAD_TIMES!!>', str.encode(str(cast_time)[:5]))
|
|
|
|
|
except:
|
|
|
|
|
pass
|
|
|
|
|
return response
|
|
|
|
|
|