fix: changed certified members count based on filters
This commit is contained in:
@@ -127,6 +127,7 @@ const memberCount = ref(0)
|
||||
const dayjs = inject('$dayjs')
|
||||
|
||||
onMounted(() => {
|
||||
getMemberCount()
|
||||
updateParticipants()
|
||||
})
|
||||
|
||||
@@ -138,11 +139,13 @@ const participants = createListResource({
|
||||
pageLength: 30,
|
||||
})
|
||||
|
||||
const count = call('lms.lms.api.get_count_of_certified_members').then(
|
||||
(data) => {
|
||||
const getMemberCount = () => {
|
||||
call('lms.lms.api.get_count_of_certified_members', {
|
||||
filters: filters.value,
|
||||
}).then((data) => {
|
||||
memberCount.value = data
|
||||
}
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
const categories = createListResource({
|
||||
doctype: 'LMS Certificate',
|
||||
@@ -157,6 +160,7 @@ const categories = createListResource({
|
||||
|
||||
const updateParticipants = () => {
|
||||
updateFilters()
|
||||
getMemberCount()
|
||||
participants.update({
|
||||
filters: filters.value,
|
||||
})
|
||||
|
||||
@@ -457,7 +457,7 @@ class CountDistinct(DistinctOptionFunction):
|
||||
|
||||
|
||||
@frappe.whitelist(allow_guest=True)
|
||||
def get_count_of_certified_members():
|
||||
def get_count_of_certified_members(filters=None):
|
||||
Certificate = DocType("LMS Certificate")
|
||||
|
||||
query = (
|
||||
@@ -466,6 +466,14 @@ def get_count_of_certified_members():
|
||||
.where(Certificate.published == 1)
|
||||
)
|
||||
|
||||
if filters:
|
||||
for field, value in filters.items():
|
||||
if field == "category":
|
||||
query = query.where(
|
||||
Certificate.course_title.like(f"%{value}%")
|
||||
| Certificate.batch_title.like(f"%{value}%")
|
||||
)
|
||||
|
||||
result = query.run(as_dict=True)
|
||||
return result[0]["total"] if result else 0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user