Skip to content

Commit

Permalink
3시 기준으로 요일 변경되도록 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
Gyaak committed Aug 24, 2024
1 parent 0077439 commit 46e3c10
Showing 1 changed file with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,12 @@ public List<BusStatRespDto> getBusStat(BusStatReqDto busStatReqDto) {

public List<BusStatRespDto> getBusStatNow(Long routeId, Long stationId) {
LocalDateTime now = LocalDateTime.now();
int startTime = getTime(now.minusMinutes(30));
int endTime = getTime(now.plusMinutes(30));
return busStatRepository.findByRouteIdAndStationIdAndDayOfWeekBetweenNow(
routeId,
stationId,
now.getDayOfWeek().getValue(),
startTime,
endTime
getDayOfWeek(now),
getTime(now.minusMinutes(30)),
getTime(now.plusMinutes(30))
).stream()
.map(BusStatRespDto::of)
.toList();
Expand Down Expand Up @@ -115,7 +113,7 @@ private static BusStatEntity toBusStatEntity(BusLocationEntity before, BusLocati
.afterTime(after.getCreatedAt())
.plateNo(after.getPlateNo())
.plateType(after.getPlateType())
.dayOfWeek(before.getCreatedAt().getDayOfWeek().getValue())
.dayOfWeek(getDayOfWeek(before.getCreatedAt()))
.time(getTime(before.getCreatedAt()))
.build();
}
Expand All @@ -125,6 +123,13 @@ private static int getTime(LocalDateTime localDateTime) {
return localDateTime.getHour() * 100 + localDateTime.getMinute();
}

private static int getDayOfWeek(LocalDateTime localDateTime) {
if (localDateTime.getHour() < 3) {
return localDateTime.getDayOfWeek().getValue() - 1;
}
return localDateTime.getDayOfWeek().getValue();
}

// old logic
// @Deprecated
// @Transactional
Expand Down

0 comments on commit 46e3c10

Please sign in to comment.