From b4068c5e0f7a203f57089280f3c85c4b9e50439e Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 25 Apr 2022 00:25:12 +0200 Subject: [PATCH] remove dead middleware --- InvenTree/InvenTree/middleware.py | 61 ------------------------------- 1 file changed, 61 deletions(-) diff --git a/InvenTree/InvenTree/middleware.py b/InvenTree/InvenTree/middleware.py index a9c43c71b6..1e9ada3cfa 100644 --- a/InvenTree/InvenTree/middleware.py +++ b/InvenTree/InvenTree/middleware.py @@ -92,67 +92,6 @@ class AuthRequiredMiddleware(object): return response -class QueryCountMiddleware(object): - """ - This middleware will log the number of queries run - and the total time taken for each request (with a - status code of 200). It does not currently support - multi-db setups. - - To enable this middleware, set 'log_queries: True' in the local InvenTree config file. - - Reference: https://www.dabapps.com/blog/logging-sql-queries-django-13/ - - Note: 2020-08-15 - This is no longer used, instead we now rely on the django-debug-toolbar addon - """ - - def __init__(self, get_response): - self.get_response = get_response - - def __call__(self, request): - - t_start = time.time() - response = self.get_response(request) - t_stop = time.time() - - if response.status_code == 200: - total_time = 0 - - if len(connection.queries) > 0: - - queries = {} - - for query in connection.queries: - query_time = query.get('time') - - sql = query.get('sql').split('.')[0] - - if sql in queries: - queries[sql] += 1 - else: - queries[sql] = 1 - - if query_time is None: - # django-debug-toolbar monkeypatches the connection - # cursor wrapper and adds extra information in each - # item in connection.queries. The query time is stored - # under the key "duration" rather than "time" and is - # in milliseconds, not seconds. - query_time = float(query.get('duration', 0)) - - total_time += float(query_time) - - logger.debug('{n} queries run, {a:.3f}s / {b:.3f}s'.format( - n=len(connection.queries), - a=total_time, - b=(t_stop - t_start))) - - for x in sorted(queries.items(), key=operator.itemgetter(1), reverse=True): - print(x[0], ':', x[1]) - - return response - - url_matcher = url('', include(frontendpatterns))