Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,17 @@ public List<RecommendResponseDto> putRecommendMovieListIfAbsent() {
double total = 0;
Long movieId = entry.getKey();

total += 3 * favoriteService.countFavoriteMovieList(movieId);
total += 2 * (entry.getValue() - 2);
total += (rankMap.get(movieId) != null) ? 2 - (0.1 * (rankMap.get(movieId) - 1)) : 0;
long favoriteCount = favoriteService.countFavoriteMovieList(movieId);
total += calculateFavoriteScore(favoriteCount);

Double sentiment = entry.getValue();
total += calculateSentimentScore(sentiment);

Integer rank = rankMap.get(movieId);
total += calculateRankScore(rank);

MovieResponseDto movieResponseDto = movieService.getMovieDetailsByMovieId(movieId);
movieResponseDto.updateFavoriteCount(favoriteService.countFavoriteMovieList(movieId));
movieResponseDto.updateFavoriteCount(favoriteCount);

RecommendResponseDto recommendResponseDto = RecommendResponseDto.builder()
.movieId(movieId)
Expand Down Expand Up @@ -127,4 +132,16 @@ public List<RecommendResponseDto> putRecommendMovieListIfAbsent() {
}
}
}

private double calculateFavoriteScore(long favoriteCount) {
return 3 * favoriteCount;
}

private double calculateSentimentScore(Double sentiment) {
return (sentiment != 0) ? 2 * (sentiment - 2) : 0;
}

private double calculateRankScore(Integer rank) {
return (rank != null) ? 2 - (0.1 * (rank - 1)) : 0;
}
}