Skip to content

Commit

Permalink
Merge pull request #401 from SWM-NM/feat/#399
Browse files Browse the repository at this point in the history
♻️ [REFACTOR] HeatMap 쿼리 수정 -> 조인 사용 #399
  • Loading branch information
miiiinju1 authored Oct 5, 2023
2 parents 3f769e0 + 35c176e commit c5c1d30
Showing 1 changed file with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,23 @@ public interface AttemptProblemRepository extends JpaRepository<AttemptProblem,
// from attempt_problem where test_id = (select test_id from tests t left join t.member m where t.member_id = m.member_id and between 1 year ago and now() and t.test_status = 'COMPLETED' order by t.test_date desc )
// is_solved = true
// group by test_date;
// @Query("SELECT a.testDate, count(a.testDate) " +
// "FROM AttemptProblem a " +
// "WHERE a.test.testId IN " +
// "(SELECT DISTINCT t.testId " +
// "FROM Tests t " +
// "WHERE t.member.memberId = :memberId " +
// "AND (t.testDate BETWEEN :oneYearAgo AND CURRENT_TIMESTAMP) " +
// "AND t.testStatus = 'COMPLETED') " +
// "AND a.isSolved = true " +
// "GROUP BY a.testDate " +
// "ORDER BY a.testDate DESC")
@Query("SELECT a.testDate, count(a.testDate) " +
"FROM AttemptProblem a " +
"WHERE a.test.testId IN " +
"(SELECT DISTINCT t.testId " +
"FROM Tests t " +
"WHERE t.member.memberId = :memberId " +
"AND (t.testDate BETWEEN :oneYearAgo AND CURRENT_TIMESTAMP) " +
"AND t.testStatus = 'COMPLETED') " +
"JOIN a.test t " +
"WHERE a.member.memberId = :memberId " +
"AND a.isSolved = true " +
"AND (t.testDate BETWEEN :oneYearAgo AND CURRENT_TIMESTAMP) " +
"GROUP BY a.testDate " +
"ORDER BY a.testDate DESC")
List<Object[]> getHeatMapDataSinceOneYear(@Param("memberId") Long memberId, @Param("oneYearAgo") LocalDateTime oneYearAgo);
Expand Down

0 comments on commit c5c1d30

Please sign in to comment.