From 19a65ac45f2381e1802e9d920ce289d9e14b656a Mon Sep 17 00:00:00 2001 From: Herculino Trotta Date: Wed, 29 Jan 2025 00:12:47 -0300 Subject: [PATCH] feat: reduce db queries when saving order on session --- app/WYGIWYH/settings.py | 2 +- app/apps/monthly_overview/views.py | 3 ++- app/apps/transactions/views/transactions.py | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/WYGIWYH/settings.py b/app/WYGIWYH/settings.py index 636956b..14d9a09 100644 --- a/app/WYGIWYH/settings.py +++ b/app/WYGIWYH/settings.py @@ -222,7 +222,7 @@ SESSION_COOKIE_SECURE = os.getenv("HTTPS_ENABLED", "false").lower() == "true" DEBUG_TOOLBAR_CONFIG = { "ROOT_TAG_EXTRA_ATTRS": "hx-preserve", - "SHOW_TOOLBAR_CALLBACK": lambda r: False, # disables it} + # "SHOW_TOOLBAR_CALLBACK": lambda r: False, # disables it } DEBUG_TOOLBAR_PANELS = [ "debug_toolbar.panels.history.HistoryPanel", diff --git a/app/apps/monthly_overview/views.py b/app/apps/monthly_overview/views.py index 7ccae83..484e281 100644 --- a/app/apps/monthly_overview/views.py +++ b/app/apps/monthly_overview/views.py @@ -69,7 +69,8 @@ def transactions_list(request, month: int, year: int): if "order" in request.GET: order = request.GET["order"] - request.session["monthly_transactions_order"] = order + if order != request.session["monthly_transactions_order"]: + request.session["monthly_transactions_order"] = order f = TransactionsFilter(request.GET) transactions_filtered = ( diff --git a/app/apps/transactions/views/transactions.py b/app/apps/transactions/views/transactions.py index 186214b..482825d 100644 --- a/app/apps/transactions/views/transactions.py +++ b/app/apps/transactions/views/transactions.py @@ -328,7 +328,8 @@ def transaction_all_list(request): if "order" in request.GET: order = request.GET["order"] - request.session["all_transactions_order"] = order + if order != request.session["all_transactions_order"]: + request.session["all_transactions_order"] = order transactions = Transaction.objects.prefetch_related( "account",