perf: use cached workflow doc for transitions (#21300)

* fix: expire `RECORDER_INTERCEPT_FLAG` in one hour

Leaving this running in prod can be dangerous.

* perf: Use cached doc in workflows
This commit is contained in:
Ankush Menat 2023-06-09 12:43:40 +05:30 committed by GitHub
parent 345da6e314
commit 774a75dbde
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View file

@ -210,7 +210,7 @@ def validate_workflow(doc):
def get_workflow(doctype) -> "Workflow":
return frappe.get_doc("Workflow", get_workflow_name(doctype))
return frappe.get_cached_doc("Workflow", get_workflow_name(doctype))
def has_approval_access(user, doc, transition):

View file

@ -169,7 +169,7 @@ def status(*args, **kwargs):
@do_not_record
@administrator_only
def start(*args, **kwargs):
frappe.cache.set_value(RECORDER_INTERCEPT_FLAG, 1)
frappe.cache.set_value(RECORDER_INTERCEPT_FLAG, 1, expires_in_sec=60 * 60)
@frappe.whitelist()