Skip to content

Commit

Permalink
Fix : 쿼리수정
Browse files Browse the repository at this point in the history
User가 날짜에있으면 조회가 안되는 버그가있어 쿼리 수정
  • Loading branch information
Mouon committed Feb 14, 2024
1 parent 1c24b32 commit 7ea84b2
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ public List<Object[]> countChatsBySenderAndDate(Long userId, Date startDate, Dat

public Sender findMostActiveSender(long userId, Date diaryDate) {
String jpql = "SELECT c.sender FROM chat c " +
"WHERE c.member.id = :memberId AND c.createAt >= :startDate AND c.createAt < :endDate " +
"WHERE c.member.id = :memberId AND c.sender != :user " +
"AND c.createAt >= :startDate AND c.createAt < :endDate " +
"GROUP BY c.sender ORDER BY COUNT(c) DESC";
TypedQuery<Sender> query = em.createQuery(jpql, Sender.class)
.setParameter("memberId", userId)
.setParameter("user", Sender.USER)
.setParameter("startDate", diaryDate.toLocalDate().atStartOfDay())
.setParameter("endDate", diaryDate.toLocalDate().plusDays(1).atStartOfDay())
.setMaxResults(1);
Expand Down

0 comments on commit 7ea84b2

Please sign in to comment.