perf: faster page view count queries (#29219)

This commit is contained in:
Ankush Menat 2025-01-17 15:16:03 +05:30 committed by GitHub
parent 800ff70af1
commit cfa4534757
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 2 deletions

View file

@ -24,7 +24,8 @@
"fieldname": "path",
"fieldtype": "Data",
"label": "Path",
"set_only_once": 1
"set_only_once": 1,
"search_index": 1
},
{
"fieldname": "referrer",

View file

@ -6,6 +6,7 @@ from urllib.parse import urlparse
import frappe
import frappe.utils
from frappe.model.document import Document
from frappe.utils.caching import redis_cache
class WebPageView(Document):
@ -101,9 +102,10 @@ def make_view_log(
@frappe.whitelist()
@redis_cache(ttl=5 * 60)
def get_page_view_count(path):
return frappe.db.count("Web Page View", filters={"path": path})
def is_tracking_enabled():
return frappe.db.get_single_value("Website Settings", "enable_view_tracking")
return frappe.get_website_settings("enable_view_tracking")