parent
487601ff5c
commit
5e242aea7a
@ -1,11 +1,21 @@
|
||||
json.current_attendance do
|
||||
json.(@current_attendance, :id, :normal_count, :all_count)
|
||||
json.(@current_attendance, :id, :normal_count, :all_count) if @current_attendance
|
||||
end
|
||||
|
||||
json.history_attendances @history_attendances do |attendance|
|
||||
all_normal_rate = []
|
||||
all_absence_rate = []
|
||||
json.history_attendances @history_attendances.each_with_index.to_a do |attendance, index|
|
||||
normal_count = history_member_count(@all_member_attendances, "NORMAL", attendance.id)
|
||||
absence_count = history_member_count(@all_member_attendances, "ABSENCE", attendance.id)
|
||||
all_count = @all_member_attendances.select{|member_attendance| member_attendance.course_attendance_id == attendance.id}.size
|
||||
|
||||
json.index index + 1
|
||||
json.normal_rate cal_rate(normal_count, all_count)
|
||||
all_normal_rate << cal_rate(normal_count, all_count)
|
||||
json.absence_rate cal_rate(absence_count, all_count)
|
||||
all_absence_rate << cal_rate(absence_count, all_count)
|
||||
end
|
||||
|
||||
json.all_history_count @all_history_count
|
||||
json.normal_count @normal_count
|
||||
json.leave_count @leave_count
|
||||
json.absence_count @absence_count
|
||||
json.avg_normal_rate all_normal_rate.sum / @all_history_count
|
||||
json.avg_absence_rate all_absence_rate.sum / @all_history_count
|
||||
|
Loading…
Reference in new issue