perf: cache and simplify queries for holiday list (#35315)
This commit is contained in:
parent
5c2d7701ea
commit
9feda1b829
@ -257,7 +257,9 @@ def get_employee_email(employee_doc):
|
|||||||
|
|
||||||
def get_holiday_list_for_employee(employee, raise_exception=True):
|
def get_holiday_list_for_employee(employee, raise_exception=True):
|
||||||
if employee:
|
if employee:
|
||||||
holiday_list, company = frappe.db.get_value("Employee", employee, ["holiday_list", "company"])
|
holiday_list, company = frappe.get_cached_value(
|
||||||
|
"Employee", employee, ["holiday_list", "company"]
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
holiday_list = ""
|
holiday_list = ""
|
||||||
company = frappe.db.get_single_value("Global Defaults", "default_company")
|
company = frappe.db.get_single_value("Global Defaults", "default_company")
|
||||||
|
@ -115,6 +115,8 @@ def is_holiday(holiday_list, date=None):
|
|||||||
if date is None:
|
if date is None:
|
||||||
date = today()
|
date = today()
|
||||||
if holiday_list:
|
if holiday_list:
|
||||||
return bool(frappe.get_all("Holiday List", dict(name=holiday_list, holiday_date=date)))
|
return bool(
|
||||||
|
frappe.db.exists("Holiday", {"parent": holiday_list, "holiday_date": date}, cache=True)
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
Loading…
x
Reference in New Issue
Block a user