take joining date into consideration while assigning duties
This commit is contained in:
parent
80959a8312
commit
a25d9a04a4
|
@ -3,6 +3,7 @@
|
|||
|
||||
import frappe
|
||||
from frappe.model.document import Document
|
||||
from operator import itemgetter
|
||||
|
||||
|
||||
class ExamGroup(Document):
|
||||
|
@ -132,11 +133,21 @@ class ExamGroup(Document):
|
|||
print(total_invigilators_required)
|
||||
for i in range(total_invigilators_required):
|
||||
if not all_staff:
|
||||
# (
|
||||
# (count, date, staff),
|
||||
# (count, date, staff),
|
||||
# ...
|
||||
# )
|
||||
all_staff = frappe.db.get_list(
|
||||
"Staff", pluck="name", order_by="duty_count asc"
|
||||
"Staff", as_list=True, fields=["duty_count", "joining_date", "name"]
|
||||
)
|
||||
|
||||
staff = all_staff.pop(0)
|
||||
all_staff = list(all_staff)
|
||||
# sort in ascending order of count
|
||||
all_staff.sort(key=itemgetter(0))
|
||||
# then by descending order of joining date
|
||||
all_staff.sort(key=itemgetter(1), reverse=True)
|
||||
print(all_staff)
|
||||
staff = all_staff.pop(0)[2]
|
||||
staff = frappe.get_doc("Staff", staff)
|
||||
print(staff)
|
||||
invigilator_child = frappe.new_doc("Invigilator And Duty")
|
||||
|
|
Loading…
Reference in New Issue