Skip to content

Commit afeb2a9

Browse files
committed
fix : 랜덤 점수
1 parent 45748f4 commit afeb2a9

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

srcs/movie/movie.model.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,15 @@ export const MovieModel = {
3333
const averageRating = await Promise.all(movies.map(async (movie) => {
3434
const [result] = await pool.query(sql.getAverageRatingByMovieId, [movie.movieId]);
3535
const rating = parseFloat(result[0].averageRating) || 0.0;
36-
if (rating === 0.0) {
36+
if (rating === 0) {
3737
const randomRatings = [3, 3.5, 4];
3838
return randomRatings[Math.floor(Math.random() * randomRatings.length)];
3939
}
4040
return rating;
4141
}));
42-
43-
await addAverageRatingToMovies(movies);
42+
movies.forEach((movie, index) => {
43+
movie.averageRating = averageRating[index];
44+
});
4445
return movies.map((movie) => ({
4546
id: movie.id,
4647
kmdbId: movie.kmdbId,

0 commit comments

Comments
 (0)