Skip to content

Commit a40b28b

Browse files
authored
Merge pull request #153 from prgrms-aibe-devcourse/fix/152-grass-graph-fixed-year
[Fix] 대시보드 잔디 그래프 API 1년 고정 조회로 변경
2 parents 47697a0 + 6f9b0fd commit a40b28b

3 files changed

Lines changed: 5 additions & 13 deletions

File tree

src/main/java/com/Rootin/domain/dashboard/controller/DashboardController.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,10 @@ public class DashboardController {
2020

2121
@GetMapping("/grass")
2222
public ResponseEntity<ApiResponse<GrassGraphResponse>> getGrassGraph(
23-
@AuthenticationPrincipal JwtUserDetails userDetails,
24-
@RequestParam(defaultValue = "3") int months
23+
@AuthenticationPrincipal JwtUserDetails userDetails
2524
) {
2625
return ResponseEntity.ok(ApiResponse.success(
27-
dashboardService.getGrassGraph(userDetails.getUserId(), months)));
26+
dashboardService.getGrassGraph(userDetails.getUserId())));
2827
}
2928

3029
@GetMapping("/weekly")

src/main/java/com/Rootin/domain/dashboard/dto/GrassGraphResponse.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,7 @@
22

33
import java.util.List;
44

5-
/**
6-
* 잔디 그래프 API 응답 DTO.
7-
* cells: 해당 연도의 날짜별 작성 현황
8-
* currentStreak: 현재 연속 작성일 수
9-
* maxStreak: 조회 연도 내 최대 연속 작성일 수
10-
*/
115
public record GrassGraphResponse(
12-
int months,
136
List<GrassCell> cells,
147
int currentStreak,
158
int maxStreak

src/main/java/com/Rootin/domain/dashboard/service/DashboardService.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ public class DashboardService {
4040
private final PointLogRepository pointLogRepository;
4141
private final LevelCalculator levelCalculator;
4242

43-
public GrassGraphResponse getGrassGraph(Long userId, int months) {
43+
public GrassGraphResponse getGrassGraph(Long userId) {
4444
LocalDate today = LocalDate.now();
45-
LocalDateTime from = today.minusMonths(months).atStartOfDay();
45+
LocalDateTime from = today.minusYears(1).atStartOfDay();
4646
LocalDateTime to = today.atTime(23, 59, 59);
4747
List<WateringLog> logs = wateringLogRepository.findByUserIdAndWateredAtBetween(userId, from, to);
4848

@@ -64,7 +64,7 @@ public GrassGraphResponse getGrassGraph(Long userId, int months) {
6464
int currentStreak = levelCalculator.calculateStreak(publishedTimes);
6565
int maxStreak = calculateMaxStreak(byDate.keySet());
6666

67-
return new GrassGraphResponse(months, cells, currentStreak, maxStreak);
67+
return new GrassGraphResponse(cells, currentStreak, maxStreak);
6868
}
6969

7070
public WeeklyStatsResponse getWeeklyStats(Long userId) {

0 commit comments

Comments
 (0)