Add support for django-query-count (#6948)

* Add support for django-query-count

* Display duplicate queries

* Add comment in settings.py
This commit is contained in:
Oliver 2024-04-04 13:33:32 +11:00 committed by GitHub
parent fddcb629b6
commit 7ca420ebdc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 22 additions and 0 deletions

View File

@ -268,6 +268,26 @@ MIDDLEWARE = CONFIG.get(
],
)
# In DEBUG mode, add support for django-querycount
# Ref: https://github.com/bradmontgomery/django-querycount
if DEBUG and get_boolean_setting(
'INVENTREE_DEBUG_QUERYCOUNT', 'debug_querycount', False
):
MIDDLEWARE.append('querycount.middleware.QueryCountMiddleware')
QUERYCOUNT = {
'THRESHOLDS': {
'MEDIUM': 50,
'HIGH': 200,
'MIN_TIME_TO_LOG': 0,
'MIN_QUERY_COUNT_TO_LOG': 0,
},
'IGNORE_REQUEST_PATTERNS': ['^(?!\/(api)?(plugin)?\/).*'],
'IGNORE_SQL_PATTERNS': [],
'DISPLAY_DUPLICATES': 3,
'RESPONSE_HEADER': 'X-Django-Query-Count',
}
AUTHENTICATION_BACKENDS = CONFIG.get(
'authentication_backends',
[

View File

@ -2,6 +2,7 @@
-c requirements.txt
coverage[toml] # Unit test coverage
coveralls==2.1.2 # Coveralls linking (for tracking coverage) # PINNED 2022-06-28 - Old version needed for correct upload
django-querycount # Display number of URL queries for requests
django-slowtests # Show which unit tests are running slowly
django-test-migrations # Unit testing for database migrations
isort # python import sorting

View File

@ -25,6 +25,7 @@ distlib==0.3.8
# via virtualenv
django==4.2.11
# via django-slowtests
django-querycount==0.8.3
django-slowtests==1.1.1
django-test-migrations==1.3.0
docopt==0.6.2