perf: cache get_events on desk load

This commit is contained in:
Ankush Menat 2025-01-23 12:06:36 +05:30
parent f177bb28a7
commit 2b1df9aa56
3 changed files with 5 additions and 2 deletions

View file

@ -25,6 +25,7 @@ from frappe.utils import (
now_datetime,
nowdate,
)
from frappe.utils.caching import http_cache
from frappe.utils.user import get_enabled_system_users
weekdays = ["monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"]
@ -263,6 +264,7 @@ def send_event_digest():
@frappe.whitelist()
@http_cache(max_age=5 * 60, stale_while_revalidate=60 * 60)
def get_events(start, end, user=None, for_reminder=False, filters=None) -> list[frappe._dict]:
if not user:
user = frappe.session.user

View file

@ -165,7 +165,7 @@ def get_email_header(doc, language: str | None = None):
@frappe.whitelist()
@http_cache(max_age=60, stale_while_revalidate=5 * 60)
@http_cache(max_age=60, stale_while_revalidate=60 * 60)
def get_notification_logs(limit=20):
notification_logs = frappe.db.get_list(
"Notification Log", fields=["*"], limit=limit, order_by="creation desc"

View file

@ -393,7 +393,8 @@ class EventsView extends BaseNotificationsView {
start: today,
end: today,
},
"GET"
"GET",
{ cache: true }
)
.then((event_list) => {
this.render_events_html(event_list);