From 9e3ef5e8c75b771ea022da66189959e488814dfa Mon Sep 17 00:00:00 2001 From: arul-foureals Date: Fri, 3 Jan 2025 20:08:23 +0000 Subject: [PATCH 1/4] doc update json body changed --- src/grant/grant.service.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/grant/grant.service.ts b/src/grant/grant.service.ts index 324b175..1a0a0f5 100644 --- a/src/grant/grant.service.ts +++ b/src/grant/grant.service.ts @@ -41,7 +41,13 @@ export class GrantService { index: this.config.get('ELASTIC_INDEX'), id: grantId, body: { - 'fields.grantUpdated.en-US': false, + doc: { + fields: { + grantUpdated: { + 'en-US': false, + } + } + } }, }); console.log('Grant ID :' + grantId + ' updated to false..'); From 0564edd66a03d2945bbf789ad524156496e993b0 Mon Sep 17 00:00:00 2001 From: arul-foureals Date: Fri, 3 Jan 2025 20:13:26 +0000 Subject: [PATCH 2/4] lint fix --- src/grant/grant.service.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/grant/grant.service.ts b/src/grant/grant.service.ts index 1a0a0f5..59ed177 100644 --- a/src/grant/grant.service.ts +++ b/src/grant/grant.service.ts @@ -45,9 +45,9 @@ export class GrantService { fields: { grantUpdated: { 'en-US': false, - } - } - } + }, + }, + }, }, }); console.log('Grant ID :' + grantId + ' updated to false..'); From 4b6d994e8fbb7d2442512b2bdb9259d8d7624dd9 Mon Sep 17 00:00:00 2001 From: arul-foureals Date: Fri, 3 Jan 2025 20:57:06 +0000 Subject: [PATCH 3/4] mock added --- src/grant/grant.service.ts | 2 +- src/notifications/v2/notifications.grant.service.spec.ts | 2 ++ src/notifications/v2/notifications.grant.service.ts | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/grant/grant.service.ts b/src/grant/grant.service.ts index 59ed177..60c68eb 100644 --- a/src/grant/grant.service.ts +++ b/src/grant/grant.service.ts @@ -32,7 +32,7 @@ export class GrantService { return ids; } - async setGrantUpdatedToFalse(grantIds: string[]) { + async setGrantUpdatedToFalse(grantIds: string[]): Promise { console.log('Updating elastic index for grantUpdated to false'); console.log('Updating elasticsearch - total:' + grantIds.length); for (const grantId of grantIds) { diff --git a/src/notifications/v2/notifications.grant.service.spec.ts b/src/notifications/v2/notifications.grant.service.spec.ts index abc10b2..9386dfe 100644 --- a/src/notifications/v2/notifications.grant.service.spec.ts +++ b/src/notifications/v2/notifications.grant.service.spec.ts @@ -20,6 +20,7 @@ describe('NotificationsService', () => { let newsletterService: NewsletterService; const mockFindAllUpdatedGrants = jest.fn(); + const mockSetGrantUpdatedToFalse = jest.fn(); const mockFindAllByContentGrantSubscriptionId = jest.fn(); const mockFindAllUpcomingClosingGrants = jest.fn(); const mockFindAllUpcomingOpeningGrants = jest.fn(); @@ -122,6 +123,7 @@ describe('NotificationsService', () => { findAllUpcomingOpeningGrants: mockFindAllUpcomingOpeningGrants, findAllUpdatedGrants: mockFindAllUpdatedGrants, + setGrantUpdatedToFalse:mockSetGrantUpdatedToFalse, findGrantsPublishedAfterDate: jest.fn(), findGrantsMatchingFilterCriteria: jest.fn(), }, diff --git a/src/notifications/v2/notifications.grant.service.ts b/src/notifications/v2/notifications.grant.service.ts index d7982ff..d73b3b4 100644 --- a/src/notifications/v2/notifications.grant.service.ts +++ b/src/notifications/v2/notifications.grant.service.ts @@ -224,7 +224,7 @@ export class GrantNotificationsService { 'en-US': false, }, }); - await this.grantService.setGrantUpdatedToFalse(grantIds); + const res = await this.grantService.setGrantUpdatedToFalse(grantIds); console.log( `[CRON GRANT UPDATED] Finished updating contentful entries`, ); From b99106cc9b4c322885b766614375103a3dbc932f Mon Sep 17 00:00:00 2001 From: arul-foureals Date: Fri, 3 Jan 2025 20:59:24 +0000 Subject: [PATCH 4/4] lint fixed --- src/notifications/v2/notifications.grant.service.spec.ts | 2 +- src/notifications/v2/notifications.grant.service.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/notifications/v2/notifications.grant.service.spec.ts b/src/notifications/v2/notifications.grant.service.spec.ts index 9386dfe..5387934 100644 --- a/src/notifications/v2/notifications.grant.service.spec.ts +++ b/src/notifications/v2/notifications.grant.service.spec.ts @@ -123,7 +123,7 @@ describe('NotificationsService', () => { findAllUpcomingOpeningGrants: mockFindAllUpcomingOpeningGrants, findAllUpdatedGrants: mockFindAllUpdatedGrants, - setGrantUpdatedToFalse:mockSetGrantUpdatedToFalse, + setGrantUpdatedToFalse: mockSetGrantUpdatedToFalse, findGrantsPublishedAfterDate: jest.fn(), findGrantsMatchingFilterCriteria: jest.fn(), }, diff --git a/src/notifications/v2/notifications.grant.service.ts b/src/notifications/v2/notifications.grant.service.ts index d73b3b4..d7982ff 100644 --- a/src/notifications/v2/notifications.grant.service.ts +++ b/src/notifications/v2/notifications.grant.service.ts @@ -224,7 +224,7 @@ export class GrantNotificationsService { 'en-US': false, }, }); - const res = await this.grantService.setGrantUpdatedToFalse(grantIds); + await this.grantService.setGrantUpdatedToFalse(grantIds); console.log( `[CRON GRANT UPDATED] Finished updating contentful entries`, );