We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 45748f4 commit afeb2a9Copy full SHA for afeb2a9
1 file changed
srcs/movie/movie.model.js
@@ -33,14 +33,15 @@ export const MovieModel = {
33
const averageRating = await Promise.all(movies.map(async (movie) => {
34
const [result] = await pool.query(sql.getAverageRatingByMovieId, [movie.movieId]);
35
const rating = parseFloat(result[0].averageRating) || 0.0;
36
- if (rating === 0.0) {
+ if (rating === 0) {
37
const randomRatings = [3, 3.5, 4];
38
return randomRatings[Math.floor(Math.random() * randomRatings.length)];
39
}
40
return rating;
41
}));
42
-
43
- await addAverageRatingToMovies(movies);
+ movies.forEach((movie, index) => {
+ movie.averageRating = averageRating[index];
44
+ });
45
return movies.map((movie) => ({
46
id: movie.id,
47
kmdbId: movie.kmdbId,
0 commit comments