Skip to content

Commit

Permalink
fix : 일일 최대 찌르기 History 조회 쿼리 Between으로 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
yummygyudon committed Dec 26, 2023
1 parent 1339db4 commit f2f9577
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.sopt.app.application.poke;

import java.time.LocalDate;
import java.time.LocalTime;
import java.util.List;
import lombok.RequiredArgsConstructor;
import lombok.val;
Expand Down Expand Up @@ -49,8 +51,9 @@ public Page<PokeHistory> getAllPokedHistoryOrderByMostRecent(Long userId, Pageab
}

public void checkUserOverDailyPokeLimit(Long userId) {
LocalDateTime today = LocalDateTime.now();
List<PokeHistory> allByPokerIdAndCreatedAtDate = pokeHistoryRepository.findAllByPokerIdAndCreatedAt(userId, today);
LocalDateTime startDatetime = LocalDateTime.of(LocalDate.now(), LocalTime.of(0,0,0));
LocalDateTime endDatetime = LocalDateTime.of(LocalDate.now(), LocalTime.of(23,59,59));
List<PokeHistory> allByPokerIdAndCreatedAtDate = pokeHistoryRepository.findAllByPokerIdAndCreatedAtBetween(userId, startDatetime, endDatetime);
if (allByPokerIdAndCreatedAtDate.size() >= 10) {
throw new BadRequestException(ErrorCode.OVER_DAILY_POKE_LIMIT.getMessage());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public interface PokeHistoryRepository extends JpaRepository<PokeHistory, Long>
Optional<PokeHistory> findByPokerIdAndPokedIdAndIsReplyIsFalse(Long pokerId, Long pokedId);

List<PokeHistory> findAllByPokerId(Long userId);
List<PokeHistory> findAllByPokerIdAndCreatedAt(Long userId, LocalDateTime date);
List<PokeHistory> findAllByPokerIdAndCreatedAtBetween(Long userId, LocalDateTime start, LocalDateTime end);

List<PokeHistory> findAllByPokerIdAndIsReply(Long userId, boolean isReply);
List<PokeHistory> findAllByPokedIdAndIsReply(Long userId, boolean isReply);
Expand Down

0 comments on commit f2f9577

Please sign in to comment.