Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.springframework.data.repository.query.Param;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Optional;

public interface RecordHealthDataRepository extends Repository<RecordHealthData, Long> {
Expand All @@ -27,7 +28,7 @@ public interface RecordHealthDataRepository extends Repository<RecordHealthData,
"COALESCE(SUM(h.zone5Seconds), 0) " +
"FROM Record r LEFT JOIN RecordHealthData h ON r.id = h.record.id " +
"WHERE r.runnectUser.id = :userId AND r.createdAt >= :startDate AND r.createdAt < :endDate")
Object[] getHealthSummary(@Param("userId") Long userId,
@Param("startDate") LocalDateTime startDate,
@Param("endDate") LocalDateTime endDate);
List<Object[]> getHealthSummary(@Param("userId") Long userId,
@Param("startDate") LocalDateTime startDate,
@Param("endDate") LocalDateTime endDate);
}
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ public GetHealthSummaryResponseDto getHealthSummary(Long userId, String startDat
LocalDateTime endDateTime = endDate.plusDays(1).atStartOfDay();

// 3. 통계 쿼리 실행
Object[] result = recordHealthDataRepository.getHealthSummary(userId, startDateTime, endDateTime);
List<Object[]> results = recordHealthDataRepository.getHealthSummary(userId, startDateTime, endDateTime);
Object[] result = results.isEmpty() ? new Object[10] : results.get(0);

Long totalRecords = result[0] != null ? ((Number) result[0]).longValue() : 0L;
Long recordsWithHealth = result[1] != null ? ((Number) result[1]).longValue() : 0L;
Expand Down
Loading