rename get_debug_queries to get_recorded_queries

This commit is contained in:
deflax 2024-03-31 18:36:55 +03:00
parent 5c8597a957
commit 413176b4a0
4 changed files with 12 additions and 12 deletions

View file

@ -1,6 +1,6 @@
from flask import render_template, abort, redirect, url_for, abort, flash, request, current_app, make_response, g
from flask_login import fresh_login_required, login_user, logout_user
from flask_sqlalchemy import get_debug_queries
from flask_sqlalchemy import get_recorded_queries
from . import admin
@ -16,7 +16,7 @@ from datetime import datetime, timedelta, date, time
@admin.after_app_request
def after_request(response):
for query in get_debug_queries():
for query in get_recorded_queries():
if query.duration >= current_app.config['SLOW_DB_QUERY_TIME']:
current_app.logger.warning('Slow query: %s\nParameters: %s\nDuration: %fs\nContext: %s\n' % (query.statement, query.parameters, query.duration, query.context))
return response

View file

@ -50,19 +50,19 @@ csrf = CSRFProtect(app)
moment = Moment(app)
moment.init_app(app)
from .main import main as main_blueprint
from main import main as main_blueprint
app.register_blueprint(main_blueprint)
from .panel import panel as panel_blueprint
from panel import panel as panel_blueprint
app.register_blueprint(panel_blueprint, url_prefix='/panel')
from .auth import auth as auth_blueprint
from auth import auth as auth_blueprint
app.register_blueprint(auth_blueprint, url_prefix='/auth')
from .admin import admin as admin_blueprint
from admin import admin as admin_blueprint
app.register_blueprint(admin_blueprint, url_prefix='/' + app.config['ADMIN_PREFIX'])
from .settings import settings as settings_blueprint
from settings import settings as settings_blueprint
app.register_blueprint(settings_blueprint, url_prefix='/settings')
@app.errorhandler(403)

View file

@ -1,6 +1,6 @@
from flask import render_template, abort, redirect, url_for, abort, flash, request, current_app, make_response, g
from flask_login import login_required, login_user, logout_user, current_user
from flask_sqlalchemy import get_debug_queries
from flask_sqlalchemy import get_recorded_queries
from . import main
from .forms import LoginForm, RegistrationForm
@ -12,7 +12,7 @@ import base64
@main.after_app_request
def after_request(response):
for query in get_debug_queries():
for query in get_recorded_queries():
if query.duration >= current_app.config['SLOW_DB_QUERY_TIME']:
current_app.logger.warning('Slow query: %s\nParameters: %s\nDuration: %fs\nContext: %s\n' % (query.statement, query.parameters, query.duration, query.context))
return response

View file

@ -1,6 +1,6 @@
from flask import render_template, abort, redirect, url_for, abort, flash, request, current_app, make_response, g
flask import render_template, abort, redirect, url_for, abort, flash, request, current_app, make_response, g
from flask_login import login_required, login_user, logout_user, current_user
from flask_sqlalchemy import get_debug_queries
from flask_sqlalchemy import get_recorded_queries
from . import panel
from .. import db
@ -12,7 +12,7 @@ from datetime import date, time, datetime
@panel.after_app_request
def after_request(response):
for query in get_debug_queries():
for query in get_recorded_queries():
if query.duration >= current_app.config['SLOW_DB_QUERY_TIME']:
current_app.logger.warning('Slow query: %s\nParameters: %s\nDuration: %fs\nContext: %s\n' % (query.statement, query.parameters, query.duration, query.context))
return response