Skip to content

Commit

Permalink
Merge pull request #141 from beyond-sw-camp/refactor/program/read-filter
Browse files Browse the repository at this point in the history
[Refactor] 프로그램 정렬 기준 변경 #140
  • Loading branch information
postrel63 authored Aug 8, 2024
2 parents 66211dd + 7215fd6 commit acd2c3e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ out/
### VS Code ###
.vscode/

appplication.yml
appplication-local.yml
/gradle/wrapper/gradle-wrapper.jar
/gradle/wrapper/gradle-wrapper.properties
/gradlew
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,15 @@ public List<Program> readRealTimeAll(LocalDateTime currentDateTime) throws BaseE
public List<Program> readRealTimeAllPaged(ReadProgramCommand command) throws BaseException {
int page = command.getPage();
int size = command.getSize();
LocalDateTime currentDateTime = LocalDateTime.now();
// 현재 시간을 기준으로 예매 끝난 공연은 나오지 않게 하는 filter
// LocalDateTime currentDateTime = LocalDateTime.now();

Pageable pageable = PageRequest.of(page, size);
Page<ProgramEntity> programEntityPage = jpaProgramRepository.findAll(pageable);

List<Program> programs = programEntityPage.stream()
.filter(p -> p.getReservationOpenDate().isAfter(currentDateTime))
.sorted(Comparator.comparing(ProgramEntity::getReservationOpenDate)) // 예약 오픈 날짜 기준 정렬
// .filter(p -> p.getReservationOpenDate().isAfter(currentDateTime))
.sorted(Comparator.comparing(ProgramEntity::getProgramEndDate)) // 예약 오픈 날짜 기준 정렬
.map(p -> Program.builder()
.id(p.getId())
.categoryId(p.getCategoryEntity().getId())
Expand Down

0 comments on commit acd2c3e

Please sign in to comment.