Skip to content

Commit

Permalink
fix:독립 영화 asc로 반환하기로 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
AlmondBreez3 committed Jan 29, 2024
1 parent cf35f9c commit d78cd55
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public String uploadImage(MultipartFile file) throws IOException {
public Screening execute(PostScreeningRequest request) {
Long userId = SecurityUtil.getCurrentUserId();
validateExecution(userId);
System.out.println(request.getHostName());

final HostInfo hostInfo = HostInfo.of(
request.getHostName(),
request.getHostPhoneNumber(),
Expand All @@ -55,7 +55,7 @@ public Screening execute(PostScreeningRequest request) {
request.isHasAgreed(),
request.getCategory()
);
System.out.print("finished");

Screening screen = screeningAdaptor.save(newScreening);
process(screen,userId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
import com.querydsl.jpa.impl.JPAQueryFactory;
import lombok.RequiredArgsConstructor;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.temporal.WeekFields;
import java.util.List;
import java.util.stream.Collectors;

Expand All @@ -24,17 +27,23 @@ public void save(DiverseMovie diverseMovie) {
}

public List<DiverseMovieResponseDto> findTop5ByOrderByCreatedAtDesc() {
LocalDateTime now = LocalDateTime.now();

// Get the start and end of the current week
LocalDateTime startOfWeek = LocalDate.now().with(WeekFields.ISO.dayOfWeek(), 1).atStartOfDay();
LocalDateTime endOfWeek = now;

return jpaQueryFactory
.select(new QDiverseMovieResponseDto(
diverseMovie.id,
diverseMovie.movieTitle,
diverseMovie.movieImgUrl,
diverseMovie.movieRank
)) // Change "SomeRank" to your actual rank logic
))
.from(diverseMovie)
.orderBy(diverseMovie.createdAt.desc())
.where(diverseMovie.createdAt.between(startOfWeek, endOfWeek)) // Filter movies created within the current week
.orderBy(diverseMovie.createdAt.asc())
.limit(5)
.fetch();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import java.time.DayOfWeek;
import java.time.LocalDate;
import java.util.*;
import java.util.concurrent.ThreadLocalRandom;

@Adaptor
@RequiredArgsConstructor
Expand Down Expand Up @@ -83,7 +84,7 @@ public Set<Long> generate(List<RecommendedPopcorn> thisWeekList) {
Set<Long> arr = new HashSet<>();
Random random = new Random();
while (arr.size()!=3) {
Long randomIndex = random.nextLong(thisWeekList.get(0).getId(),recommendedPopcornRepository.findAll().size()+1);
long randomIndex = ThreadLocalRandom.current().nextLong(thisWeekList.get(0).getId(), recommendedPopcornRepository.findAll().size() + 1);
arr.add(randomIndex);
}
return arr;
Expand Down

0 comments on commit d78cd55

Please sign in to comment.