From fa936c74a0afcd76427bd0b635813b8732945d05 Mon Sep 17 00:00:00 2001 From: Carlos Fornari Date: Thu, 11 Jul 2024 00:12:12 -0400 Subject: [PATCH 1/2] fix(infrastructure): :bug: query fixes --- apps/api/src/api.controller.ts | 4 ++-- .../infrastructure/queries/get-instructor-by-id.query.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/api/src/api.controller.ts b/apps/api/src/api.controller.ts index 12f80997..97890449 100644 --- a/apps/api/src/api.controller.ts +++ b/apps/api/src/api.controller.ts @@ -270,8 +270,8 @@ export class ApiController { user: comment.publisher.name, userId: comment.publisher.id, userImage: comment.publisher.image, - countLikes: comment.numberOfLikes, - countDislikes: comment.numberOfDislikes, + countLikes: comment.likes.length, + countDislikes: comment.dislikes.length, userLiked: comment.likes.includes(credentials.userId), userDisliked: comment.dislikes.includes(credentials.userId), body: comment.content, diff --git a/apps/api/src/instructor/infrastructure/queries/get-instructor-by-id.query.ts b/apps/api/src/instructor/infrastructure/queries/get-instructor-by-id.query.ts index d28dae29..53e2e99d 100644 --- a/apps/api/src/instructor/infrastructure/queries/get-instructor-by-id.query.ts +++ b/apps/api/src/instructor/infrastructure/queries/get-instructor-by-id.query.ts @@ -27,7 +27,7 @@ export class GetInstructorByIdQuery { return { id: instructor.id, name: instructor.name, - followers: instructor.followerCount, + followers: instructor.followers.length, userFollow: instructor.followers.includes(credentials.userId), location: `${instructor.city}, ${instructor.country}`, image: instructor.image, From f201da6dae78bc825a664cac10eb0140066d22bf Mon Sep 17 00:00:00 2001 From: Carlos Fornari Date: Thu, 11 Jul 2024 00:19:24 -0400 Subject: [PATCH 2/2] refactor(infrastructure): change algolia indexes --- apps/api/src/api.controller.ts | 2 +- apps/datasync/src/projectors/blog/algolia-blog.projector.ts | 2 +- .../src/projectors/course/algolia-course.projector.ts | 2 +- .../src/projectors/events/algolia-events.projector.ts | 6 +++--- .../search/providers/algolia-facets.service.ts | 4 ++-- .../search-blogs/algolia/algolia-search-blogs.service.ts | 2 +- .../algolia/algolia-search-courses.service.ts | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/apps/api/src/api.controller.ts b/apps/api/src/api.controller.ts index 97890449..98fd5e2f 100644 --- a/apps/api/src/api.controller.ts +++ b/apps/api/src/api.controller.ts @@ -384,7 +384,7 @@ export class ApiController { ) { this.algolia('clickedObjectIDs', { eventName: 'Course Clicked', - index: 'course', + index: 'courses', userToken: credentials.userId, objectIDs: [id], }); diff --git a/apps/datasync/src/projectors/blog/algolia-blog.projector.ts b/apps/datasync/src/projectors/blog/algolia-blog.projector.ts index 3182887a..705b549f 100644 --- a/apps/datasync/src/projectors/blog/algolia-blog.projector.ts +++ b/apps/datasync/src/projectors/blog/algolia-blog.projector.ts @@ -22,7 +22,7 @@ export class AlgoliaBlogProjector implements Projector, OnModuleInit { @InjectModel(MongoBlog.name) private readonly blogModel: Model, ) { - this.index = this.algolia.initIndex('blog'); + this.index = this.algolia.initIndex('blogs'); } private index: SearchIndex; diff --git a/apps/datasync/src/projectors/course/algolia-course.projector.ts b/apps/datasync/src/projectors/course/algolia-course.projector.ts index 240d79b8..875bec20 100644 --- a/apps/datasync/src/projectors/course/algolia-course.projector.ts +++ b/apps/datasync/src/projectors/course/algolia-course.projector.ts @@ -24,7 +24,7 @@ export class AlgoliaCourseProjector @InjectModel(MongoCourse.name) private readonly courseModel: Model, ) { - this.index = this.algolia.initIndex('course'); + this.index = this.algolia.initIndex('courses'); } private index: SearchIndex; diff --git a/apps/datasync/src/projectors/events/algolia-events.projector.ts b/apps/datasync/src/projectors/events/algolia-events.projector.ts index b9f0031d..ecec5d4f 100644 --- a/apps/datasync/src/projectors/events/algolia-events.projector.ts +++ b/apps/datasync/src/projectors/events/algolia-events.projector.ts @@ -25,7 +25,7 @@ export class AlgoliaEventsProjector implements Projector { ) { this.algolia('convertedObjectIDs', { eventName: 'Course Started', - index: 'course', + index: 'courses', userToken: event.context.user, objectIDs: [event.dispatcherId], }); @@ -41,7 +41,7 @@ export class AlgoliaEventsProjector implements Projector { ) { this.algolia('convertedObjectIDs', { eventName: 'Course Watched', - index: 'course', + index: 'courses', userToken: event.context.user, objectIDs: [event.dispatcherId], }); @@ -54,7 +54,7 @@ export class AlgoliaEventsProjector implements Projector { ) { this.algolia('convertedObjectIDs', { eventName: 'Course Completed', - index: 'course', + index: 'courses', userToken: event.context.user, objectIDs: [event.dispatcherId], }); diff --git a/libs/core/src/infrastructure/search/providers/algolia-facets.service.ts b/libs/core/src/infrastructure/search/providers/algolia-facets.service.ts index aaa0dd12..c010efa2 100644 --- a/libs/core/src/infrastructure/search/providers/algolia-facets.service.ts +++ b/libs/core/src/infrastructure/search/providers/algolia-facets.service.ts @@ -15,8 +15,8 @@ export class GetPopularAlgoliaFacetsService implements Service { @InjectAlgolia() private readonly algolia: SearchClient, ) { - this.blogIndex = this.algolia.initIndex('blog'); - this.courseIndex = this.algolia.initIndex('course'); + this.blogIndex = this.algolia.initIndex('blogs'); + this.courseIndex = this.algolia.initIndex('courses'); } private blogIndex: SearchIndex; diff --git a/libs/core/src/infrastructure/search/providers/search-blogs/algolia/algolia-search-blogs.service.ts b/libs/core/src/infrastructure/search/providers/search-blogs/algolia/algolia-search-blogs.service.ts index f7833ba7..0c34f89b 100644 --- a/libs/core/src/infrastructure/search/providers/search-blogs/algolia/algolia-search-blogs.service.ts +++ b/libs/core/src/infrastructure/search/providers/search-blogs/algolia/algolia-search-blogs.service.ts @@ -23,7 +23,7 @@ export class AlgoliaSearchBlogsService implements Service { @InjectAlgolia() private readonly algolia: SearchClient, ) { - this.index = this.algolia.initIndex('blog'); + this.index = this.algolia.initIndex('blogs'); } private index: SearchIndex; diff --git a/libs/core/src/infrastructure/search/providers/search-courses/algolia/algolia-search-courses.service.ts b/libs/core/src/infrastructure/search/providers/search-courses/algolia/algolia-search-courses.service.ts index 2ad882c7..310144df 100644 --- a/libs/core/src/infrastructure/search/providers/search-courses/algolia/algolia-search-courses.service.ts +++ b/libs/core/src/infrastructure/search/providers/search-courses/algolia/algolia-search-courses.service.ts @@ -25,7 +25,7 @@ export class AlgoliaSearchCoursesService @InjectAlgolia() private readonly algolia: SearchClient, ) { - this.index = this.algolia.initIndex('course'); + this.index = this.algolia.initIndex('courses'); } private index: SearchIndex;