From 29be54a35d550fce0bead30c0ebc29ec4d006c1b Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Fri, 9 Jan 2026 16:36:06 +0530 Subject: [PATCH] perf: misc v16 fixes (#35790) * perf: Reduce queries for setup wizard progress These are queried on boot continuously, can just cache installed app doc. * fix: remove stray db.commit in csrf generation --- .../installed_applications.py | 32 +++++++------------ frappe/www/desk.py | 2 -- 2 files changed, 11 insertions(+), 23 deletions(-) diff --git a/frappe/core/doctype/installed_applications/installed_applications.py b/frappe/core/doctype/installed_applications/installed_applications.py index 965d0767ac..0914ad8a68 100644 --- a/frappe/core/doctype/installed_applications/installed_applications.py +++ b/frappe/core/doctype/installed_applications/installed_applications.py @@ -6,6 +6,7 @@ import json import frappe from frappe import _ from frappe.model.document import Document +from frappe.utils.caching import redis_cache class InvalidAppOrder(frappe.ValidationError): @@ -152,24 +153,16 @@ def get_installed_app_order() -> list[str]: return frappe.get_installed_apps(_ensure_on_bench=True) -@frappe.request_cache def get_setup_wizard_completed_apps(): """Get list of apps that have completed setup wizard""" - return frappe.get_all( - "Installed Application", - filters={"has_setup_wizard": 1, "is_setup_complete": 1}, - pluck="app_name", - ) + apps: InstalledApplications = frappe.client_cache.get_doc("Installed Applications") + return [a.app_name for a in apps.installed_applications if a.has_setup_wizard and a.is_setup_complete] -@frappe.request_cache def get_setup_wizard_not_required_apps(): """Get list of apps that do not require setup wizard""" - return frappe.get_all( - "Installed Application", - filters={"has_setup_wizard": 0}, - pluck="app_name", - ) + apps: InstalledApplications = frappe.client_cache.get_doc("Installed Applications") + return [a.app_name for a in apps.installed_applications if not a.has_setup_wizard] @frappe.request_cache @@ -190,17 +183,14 @@ def get_apps_with_incomplete_dependencies(current_app): return pending_apps -@frappe.request_cache def get_setup_wizard_pending_apps(apps=None): """Get list of apps that have completed setup wizard""" - filters = {"has_setup_wizard": 1, "is_setup_complete": 0} + apps: InstalledApplications = frappe.client_cache.get_doc("Installed Applications") + pending_apps = [ + a.app_name for a in apps.installed_applications if a.has_setup_wizard and not a.is_setup_complete + ] if apps: - filters["app_name"] = ["in", apps] + pending_apps = [a for a in pending_apps if a in apps] - return frappe.get_all( - "Installed Application", - filters=filters, - order_by="idx", - pluck="app_name", - ) + return pending_apps diff --git a/frappe/www/desk.py b/frappe/www/desk.py index 24da48335b..ee7a486e87 100644 --- a/frappe/www/desk.py +++ b/frappe/www/desk.py @@ -34,8 +34,6 @@ def get_context(context): # this needs commit csrf_token = frappe.sessions.get_csrf_token() - frappe.db.commit() # nosemgrep - hooks = frappe.get_hooks() app_include_js = hooks.get("app_include_js", []) + frappe.conf.get("app_include_js", []) app_include_css = hooks.get("app_include_css", []) + frappe.conf.get("app_include_css", [])