From 46b6431269d0514acbed1f7d161532174a394aa8 Mon Sep 17 00:00:00 2001 From: Gabriela Ueno Date: Mon, 8 Apr 2024 12:37:05 -0300 Subject: [PATCH] fix: finding news by tags (#4231) --- apps/gp2-server/src/handlers/news/algolia-index-handler.ts | 7 ++++++- .../test/handlers/news/algolia-index-handler.test.ts | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/apps/gp2-server/src/handlers/news/algolia-index-handler.ts b/apps/gp2-server/src/handlers/news/algolia-index-handler.ts index 58cee6f000..aad368df62 100644 --- a/apps/gp2-server/src/handlers/news/algolia-index-handler.ts +++ b/apps/gp2-server/src/handlers/news/algolia-index-handler.ts @@ -25,8 +25,13 @@ export const indexNewsHandler = const news = await newsController.fetchById(id); log.debug(`Fetched news ${news.id}`); + const data = { + ...news, + _tags: news.tags, + }; + await algoliaClient.save({ - data: news, + data, type: 'news', }); diff --git a/apps/gp2-server/test/handlers/news/algolia-index-handler.test.ts b/apps/gp2-server/test/handlers/news/algolia-index-handler.test.ts index a33ea7863e..13d6c4a24e 100644 --- a/apps/gp2-server/test/handlers/news/algolia-index-handler.test.ts +++ b/apps/gp2-server/test/handlers/news/algolia-index-handler.test.ts @@ -24,7 +24,7 @@ describe('News index handler', () => { await indexHandler(publishedEvent('42')); expect(algoliaSearchClientMock.save).toHaveBeenCalledWith({ - data: newsResponse, + data: { ...newsResponse, _tags: newsResponse.tags }, type: 'news', }); });