diff --git a/app/controllers/attendances_controller.rb b/app/controllers/attendances_controller.rb index 000c90428..256e651e8 100644 --- a/app/controllers/attendances_controller.rb +++ b/app/controllers/attendances_controller.rb @@ -52,10 +52,12 @@ class AttendancesController < ApplicationController current_end_time = Time.current.strftime("%H:%M:%S") history_attendances = @course.course_attendances.where("attendance_date < '#{current_date}' or (attendance_date = '#{current_date}' and end_time < '#{current_end_time}')") - all_member_attendances = CourseMemberAttendance.where(course_attendance_id: history_attendances) if params[:group_id].present? history_attendances = history_attendances.joins(:course_attendance_groups).where(course_attendance_groups: {course_group_id: [params[:group_id], 0]}) - all_member_attendances = all_member_attendances.joins(:course_member).where(course_members: {course_group_id: params[:group_id]}) + all_member_attendances = CourseMemberAttendance.where(course_attendance_id: history_attendances) + .joins(:course_member).where(course_members: {course_group_id: params[:group_id]}) + else + all_member_attendances = CourseMemberAttendance.where(course_attendance_id: history_attendances) end history_attendances = history_attendances.order("attendance_date desc, start_time desc")