Skip to content

Commit

Permalink
fix: session query, attendee query 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
SHEOMM committed Feb 22, 2024
1 parent 9212c96 commit 82119ae
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ public interface AttendeeRepository extends JpaRepository<Attendee, Long> {
@Query(value = "SELECT * FROM attendee WHERE attendee.course_id = :courseId And attendee.id NOT IN (SELECT att.attendee_id FROM attendance as att WHERE att.session_id = :sessionId)", nativeQuery = true)
public List<Attendee> findAbsenteeBySessionIdWhenNoRegister(@Param("courseId") Long courseId, @Param("sessionId") Long sessionId);

@Query(value = "SELECT atdee.name as name, atda.is_attended as isAttended, atda.created_at as AttendanceTime \n"
@Query(value = "SELECT atdee.name as AttendeeName, atda.is_attended as AttendanceStatus, atda.created_at as AttendanceTime \n"
+ "FROM attendee as atdee \n"
+ "INNER JOIN attendance as atda ON atdee.id = atda.attendee_id \n"
+ "WHERE atda.session_id = :sessionId", nativeQuery = true)
public List<SessionAttendeeInfo> findSessionAttendees(@Param("sessionId") Long sessionId);


@Query(value = "SELECT atdee.name as name, atda.is_attended as isAttended, atda.created_at as AttendanceTime \n"
@Query(value = "SELECT atdee.name as AttendeeName, atda.is_attended as AttendanceStatus, atda.created_at as AttendanceTime \n"
+ "FROM attendee as atdee \n"
+ "INNER JOIN attendance as atda ON atdee.id = atda.attendee_id \n"
+ "WHERE atda.session_id = :sessionId \n"
Expand All @@ -31,7 +31,7 @@ public interface AttendeeRepository extends JpaRepository<Attendee, Long> {
+ "COUNT(case when atdc.is_attended = true then 1 end) as attendance, "
+ "COUNT(case when atdc.is_attended = false then 1 end) as absence \n"
+ "FROM attendee as attd \n"
+ "INNER JOIN attendance as atdc ON attendee.id = atdc.attendee_id \n"
+ "INNER JOIN attendance as atdc ON attd.id = atdc.attendee_id \n"
+ "WHERE attd.course_id = :courseId \n"
+ "GROUP BY attd.id", nativeQuery = true)
public List<ClassAttendeeInfo> getClassAttendancesInfo(@Param("courseId") Long courseId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
public interface SessionAttendeeInfo {
public String getAttendeeName();

public boolean getAttendanceStatus();
public Boolean getAttendanceStatus();

public LocalDateTime getAttendanceTime();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ public List<SessionAttendanceInfo> getRecentFiveSessions(Long courseId){
.absentees(sessionWithAttendance.getabsentee())
.date(sessionWithAttendance.getdate())
.name(sessionWithAttendance.getname())
.id(sessionWithAttendance.getid())
.build()
);
}
Expand Down

0 comments on commit 82119ae

Please sign in to comment.