Skip to content

Commit

Permalink
feat: add avg rating and total reviews when getting tutories detail
Browse files Browse the repository at this point in the history
  • Loading branch information
Veirt committed Dec 2, 2024
1 parent 1409640 commit 85fcbaa
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/module/tutories/tutories.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,12 @@ export class TutoriesService {

async getTutoriesDetail(tutoriesId: string) {
try {
const tutoriesDetail =
await this.tutoriesRepository.getTutoriesDetail(tutoriesId);
return tutoriesDetail;
const [tutories, { avgRating, totalReviews }] = await Promise.all([
await this.tutoriesRepository.getTutoriesDetail(tutoriesId),
await this.reviewRepository.getAverageRating(tutoriesId),
]);

return { ...tutories, avgRating, totalReviews };
} catch (error) {
logger.error(`Failed to get tutories detail: ${error}`);
}
Expand Down

0 comments on commit 85fcbaa

Please sign in to comment.