Skip to content

Commit 3a6671c

Browse files
authored
Merge pull request #178 from Runnect/fix/health-summary-500
[Fix] - GET /api/health/summary 500 μ—λŸ¬ μˆ˜μ •
2 parents 0b649e8 + bce0d92 commit 3a6671c

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

β€Žsrc/main/java/org/runnect/server/health/repository/RecordHealthDataRepository.javaβ€Ž

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import org.springframework.data.repository.query.Param;
77

88
import java.time.LocalDateTime;
9+
import java.util.List;
910
import java.util.Optional;
1011

1112
public interface RecordHealthDataRepository extends Repository<RecordHealthData, Long> {
@@ -27,7 +28,7 @@ public interface RecordHealthDataRepository extends Repository<RecordHealthData,
2728
"COALESCE(SUM(h.zone5Seconds), 0) " +
2829
"FROM Record r LEFT JOIN RecordHealthData h ON r.id = h.record.id " +
2930
"WHERE r.runnectUser.id = :userId AND r.createdAt >= :startDate AND r.createdAt < :endDate")
30-
Object[] getHealthSummary(@Param("userId") Long userId,
31-
@Param("startDate") LocalDateTime startDate,
32-
@Param("endDate") LocalDateTime endDate);
31+
List<Object[]> getHealthSummary(@Param("userId") Long userId,
32+
@Param("startDate") LocalDateTime startDate,
33+
@Param("endDate") LocalDateTime endDate);
3334
}

β€Žsrc/main/java/org/runnect/server/health/service/HealthService.javaβ€Ž

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,8 @@ public GetHealthSummaryResponseDto getHealthSummary(Long userId, String startDat
153153
LocalDateTime endDateTime = endDate.plusDays(1).atStartOfDay();
154154

155155
// 3. 톡계 쿼리 μ‹€ν–‰
156-
Object[] result = recordHealthDataRepository.getHealthSummary(userId, startDateTime, endDateTime);
156+
List<Object[]> results = recordHealthDataRepository.getHealthSummary(userId, startDateTime, endDateTime);
157+
Object[] result = results.isEmpty() ? new Object[10] : results.get(0);
157158

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

0 commit comments

Comments
Β (0)