feat: track watch time for youtube and vimeo

This commit is contained in:
Jannat Patel
2025-07-01 16:55:55 +05:30
parent 22a2e57642
commit 2837ed16a7
4 changed files with 208 additions and 64 deletions

View File

@@ -1575,15 +1575,17 @@ def track_video_watch_duration(lesson, videos):
"source": video.get("source"),
"member": frappe.session.user,
}
if frappe.db.exists("LMS Video Watch Duration", filters):
existing_record = frappe.db.get_value(
"LMS Video Watch Duration", filters, ["name", "watch_time"], as_dict=True
)
if existing_record and existing_record.watch_time < video.get("watch_time"):
frappe.db.set_value(
"LMS Video Watch Duration",
filters,
"watch_time",
video.get("watch_time"),
)
else:
elif not existing_record:
track_new_watch_time(lesson, video)