From 17b59ce4e56968adbdf7e65bd5d9441f5f082bd5 Mon Sep 17 00:00:00 2001 From: Jannat Patel Date: Thu, 16 Jan 2025 16:39:48 +0530 Subject: [PATCH 1/2] refactor: improved ui and performance for certified participants page --- frontend/src/pages/Batches.vue | 4 +- frontend/src/pages/CertifiedParticipants.vue | 208 +++++++++++++------ lms/lms/api.py | 67 ++++-- 3 files changed, 192 insertions(+), 87 deletions(-) diff --git a/frontend/src/pages/Batches.vue b/frontend/src/pages/Batches.vue index e68e6179..bd8291d7 100644 --- a/frontend/src/pages/Batches.vue +++ b/frontend/src/pages/Batches.vue @@ -68,8 +68,8 @@ v-else-if="!batches.list.loading" class="flex flex-col items-center justify-center text-sm text-gray-600 italic mt-48" > - -
+ +
{{ __('No batches found') }}
diff --git a/frontend/src/pages/CertifiedParticipants.vue b/frontend/src/pages/CertifiedParticipants.vue index 8351eb20..61c87ff5 100644 --- a/frontend/src/pages/CertifiedParticipants.vue +++ b/frontend/src/pages/CertifiedParticipants.vue @@ -1,93 +1,173 @@ + diff --git a/lms/lms/api.py b/lms/lms/api.py index b989981a..ff51a652 100644 --- a/lms/lms/api.py +++ b/lms/lms/api.py @@ -361,34 +361,59 @@ def get_evaluator_details(evaluator): @frappe.whitelist(allow_guest=True) -def get_certified_participants(): - LMSCertificate = DocType("LMS Certificate") - participants = ( - frappe.qb.from_(LMSCertificate) - .select(LMSCertificate.member) - .distinct() - .where(LMSCertificate.published == 1) - .orderby(LMSCertificate.creation, order=frappe.qb.desc) - .run(as_dict=1) +def get_certified_participants(filters=None, start=0, page_length=30, search=None): + or_filters = {} + if not filters: + filters = {} + + filters.update({"published": 1}) + + category = filters.get("category") + if category: + del filters["category"] + or_filters["course_title"] = ["like", f"%{category}%"] + or_filters["batch_title"] = ["like", f"%{category}%"] + + participants = frappe.get_all( + "LMS Certificate", + filters=filters, + or_filters=or_filters, + fields=["member"], + group_by="member", + order_by="creation desc", + start=start, + page_length=page_length, ) - participant_details = [] for participant in participants: details = frappe.db.get_value( "User", participant.member, - ["name", "full_name", "username", "user_image"], - as_dict=True, + ["full_name", "user_image", "username", "country", "headline"], + as_dict=1, ) - course_names = frappe.get_all( - "LMS Certificate", {"member": participant.member}, pluck="course" - ) - courses = [] - for course in course_names: - courses.append(frappe.db.get_value("LMS Course", course, "title")) - details["courses"] = courses - participant_details.append(details) - return participant_details + participant.update(details) + + return participants + + +@frappe.whitelist() +def get_certification_categories(): + categories = [] + docs = frappe.get_all( + "LMS Certificate", + filters={ + "published": 1, + }, + fields=["course_title", "batch_title"], + ) + + for doc in docs: + category = doc.course_title if doc.course_title else doc.batch_title + if category not in categories: + categories.append(category) + + return categories @frappe.whitelist() From bd43ed0e887e9d4601d8fed79b98c8fbc0ae4504 Mon Sep 17 00:00:00 2001 From: Jannat Patel Date: Thu, 16 Jan 2025 16:49:03 +0530 Subject: [PATCH 2/2] fix: responsive design for certified participants page --- frontend/src/pages/CertifiedParticipants.vue | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/frontend/src/pages/CertifiedParticipants.vue b/frontend/src/pages/CertifiedParticipants.vue index 61c87ff5..78c18a7a 100644 --- a/frontend/src/pages/CertifiedParticipants.vue +++ b/frontend/src/pages/CertifiedParticipants.vue @@ -4,12 +4,14 @@ > -
-
+
+
{{ __('All Certified Participants') }}
-
+
-
+