From 1a9dfcc38868283fab1ba4d4aef7577cb26b553e Mon Sep 17 00:00:00 2001 From: WorldTeacher <41587052+WorldTeacher@users.noreply.github.com> Date: Fri, 16 Jan 2026 00:28:07 +0900 Subject: [PATCH] Update query to use startTime instead of createdAt (#2272) --- .../booklore/repository/ReadingSessionRepository.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/booklore-api/src/main/java/com/adityachandel/booklore/repository/ReadingSessionRepository.java b/booklore-api/src/main/java/com/adityachandel/booklore/repository/ReadingSessionRepository.java index cef64a66f..2afdb004c 100644 --- a/booklore-api/src/main/java/com/adityachandel/booklore/repository/ReadingSessionRepository.java +++ b/booklore-api/src/main/java/com/adityachandel/booklore/repository/ReadingSessionRepository.java @@ -16,11 +16,11 @@ import java.util.List; public interface ReadingSessionRepository extends JpaRepository { @Query(""" - SELECT CAST(rs.createdAt AS LocalDate) as date, COUNT(rs) as count + SELECT CAST(rs.startTime AS LocalDate) as date, COUNT(rs) as count FROM ReadingSessionEntity rs WHERE rs.user.id = :userId - AND YEAR(rs.createdAt) = :year - GROUP BY CAST(rs.createdAt AS LocalDate) + AND YEAR(rs.startTime) = :year + GROUP BY CAST(rs.startTime AS LocalDate) ORDER BY date """) List findSessionCountsByUserAndYear(@Param("userId") Long userId, @Param("year") int year);