perf(cache): fix active SLA doctype caching (#26861)
If no SLA is configured then this query runs on EVERY `validate` call. Root cause: if not active SLA doctypes exist then `not []` evalutes to true and causes query to run again.
This commit is contained in:
parent
b92c404ed0
commit
5e428f0447
@ -281,15 +281,18 @@ def get_repeated(values):
|
||||
|
||||
|
||||
def get_documents_with_active_service_level_agreement():
|
||||
if not frappe.cache().hget("service_level_agreement", "active"):
|
||||
set_documents_with_active_service_level_agreement()
|
||||
sla_doctypes = frappe.cache().hget("service_level_agreement", "active")
|
||||
|
||||
return frappe.cache().hget("service_level_agreement", "active")
|
||||
if sla_doctypes is None:
|
||||
return set_documents_with_active_service_level_agreement()
|
||||
|
||||
return sla_doctypes
|
||||
|
||||
|
||||
def set_documents_with_active_service_level_agreement():
|
||||
active = [sla.document_type for sla in frappe.get_all("Service Level Agreement", fields=["document_type"])]
|
||||
frappe.cache().hset("service_level_agreement", "active", active)
|
||||
return active
|
||||
|
||||
|
||||
def apply(doc, method=None):
|
||||
|
Loading…
x
Reference in New Issue
Block a user