From fa9b14b58aee91ddafbcf460844799c6ef67f273 Mon Sep 17 00:00:00 2001 From: Alejandro Guzman Date: Fri, 24 Jul 2026 08:44:48 -0500 Subject: [PATCH 1/3] 5758 - Remove visitDescriptionLinks and add enqueueDescriptionLinksValidation --- src/server/controller/cycleData/links/update.ts | 4 ++-- .../dataValidation/validateDescriptions.ts | 4 ++-- .../links/enqueueDescriptionLinksValidation.ts | 13 +++++++++++++ src/server/service/links/index.ts | 2 ++ .../visitDescriptionLinks.ts | 16 ---------------- 5 files changed, 19 insertions(+), 20 deletions(-) create mode 100644 src/server/service/links/enqueueDescriptionLinksValidation.ts delete mode 100644 src/server/worker/tasks/verifyLinks/visitDescriptionLinks/visitDescriptionLinks.ts diff --git a/src/server/controller/cycleData/links/update.ts b/src/server/controller/cycleData/links/update.ts index a048154d80..adee89ece3 100644 --- a/src/server/controller/cycleData/links/update.ts +++ b/src/server/controller/cycleData/links/update.ts @@ -13,7 +13,7 @@ import { Objects } from 'utils/objects' import { BaseProtocol, DB } from 'server/db/db' import { LinkRepository } from 'server/db/repository/assessmentCycle/links' import { ActivityLogRepository } from 'server/db/repository/public/activityLog' -import { visitDescriptionLinks } from 'server/worker/tasks/verifyLinks/visitDescriptionLinks/visitDescriptionLinks' +import { LinksService } from 'server/service/links' import { visitNationalDataPointLinks } from 'server/worker/tasks/verifyLinks/visitNationalDataPointLinks/visitNationalDataPointLinks' type Props = { @@ -51,7 +51,7 @@ export const update = async (props: Props): Promise => { sectionName, }) ) - await visitDescriptionLinks({ assessment, countryIso, cycle, descriptionIdentifiers }) + await LinksService.enqueueDescriptionLinksValidation({ assessment, countryIso, cycle, descriptionIdentifiers }) } // If the link has national data point locations, we trigger the flow that updates the ndp validation cache. diff --git a/src/server/service/dataValidation/validateDescriptions.ts b/src/server/service/dataValidation/validateDescriptions.ts index 6ce35e926d..7e79a20951 100644 --- a/src/server/service/dataValidation/validateDescriptions.ts +++ b/src/server/service/dataValidation/validateDescriptions.ts @@ -3,7 +3,7 @@ import { Assessment } from 'meta/assessment/assessment' import { Cycle } from 'meta/assessment/cycle' import { CommentableDescription, DescriptionIdentifier } from 'meta/assessment/descriptionValue' -import { visitDescriptionLinks } from 'server/worker/tasks/verifyLinks/visitDescriptionLinks/visitDescriptionLinks' +import { LinksService } from 'server/service/links' import { validateDataSources } from './validateDataSources' @@ -27,7 +27,7 @@ export const validateDescriptions = async (props: Props): Promise => { sectionName, })) - await visitDescriptionLinks({ + await LinksService.enqueueDescriptionLinksValidation({ assessment, countryIso, cycle, diff --git a/src/server/service/links/enqueueDescriptionLinksValidation.ts b/src/server/service/links/enqueueDescriptionLinksValidation.ts new file mode 100644 index 0000000000..a8137766d1 --- /dev/null +++ b/src/server/service/links/enqueueDescriptionLinksValidation.ts @@ -0,0 +1,13 @@ +import { Objects } from 'utils/objects' + +import { VerifyLinksJobName } from 'server/worker/tasks/verifyLinks/jobNames' +import { addVerifyLinksJob } from 'server/worker/tasks/verifyLinks/utils/addVerifyLinksJob' +import { VerifyDescriptionLinksJobProps } from 'server/worker/tasks/verifyLinks/visitDescriptionLinks/props' + +export const enqueueDescriptionLinksValidation = async (props: VerifyDescriptionLinksJobProps): Promise => { + const { descriptionIdentifiers } = props + + if (Objects.isEmpty(descriptionIdentifiers)) return + + await addVerifyLinksJob(VerifyLinksJobName.verifyDescriptionLinks, props) +} diff --git a/src/server/service/links/index.ts b/src/server/service/links/index.ts index 2e3c65bf64..f1401fd420 100644 --- a/src/server/service/links/index.ts +++ b/src/server/service/links/index.ts @@ -1,5 +1,7 @@ +import { enqueueDescriptionLinksValidation } from 'server/service/links/enqueueDescriptionLinksValidation' import { verifyLinks } from 'server/service/links/verifyLinks' export const LinksService = { + enqueueDescriptionLinksValidation, verifyLinks, } diff --git a/src/server/worker/tasks/verifyLinks/visitDescriptionLinks/visitDescriptionLinks.ts b/src/server/worker/tasks/verifyLinks/visitDescriptionLinks/visitDescriptionLinks.ts deleted file mode 100644 index 1cb4e29409..0000000000 --- a/src/server/worker/tasks/verifyLinks/visitDescriptionLinks/visitDescriptionLinks.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { Job } from 'bullmq' - -import { Objects } from 'utils/objects' - -import { VerifyLinksJobName } from 'server/worker/tasks/verifyLinks/jobNames' -import { addVerifyLinksJob } from 'server/worker/tasks/verifyLinks/utils/addVerifyLinksJob' - -import { VerifyDescriptionLinksJobProps } from './props' - -export const visitDescriptionLinks = async (props: VerifyDescriptionLinksJobProps): Promise => { - const { descriptionIdentifiers } = props - - if (Objects.isEmpty(descriptionIdentifiers)) return undefined - - return addVerifyLinksJob(VerifyLinksJobName.verifyDescriptionLinks, props) -} From ffae49fa9f93f46fc17062726fc1b8781ceb00eb Mon Sep 17 00:00:00 2001 From: Alejandro Guzman Date: Fri, 24 Jul 2026 08:50:31 -0500 Subject: [PATCH 2/3] 5758 - Remove visitNationalDataPointLinks and add enqueueNationalDataPointLinksValidation --- .../controller/cycleData/links/update.ts | 3 +-- .../cycleData/nationalDataPoint/remove.ts | 4 ++-- .../nationalDataPoint/updateComments.ts | 4 ++-- .../nationalDataPoint/updateDataSources.ts | 4 ++-- .../cycleData/nationalDataPoint/updateYear.ts | 4 ++-- .../enqueueNationalDataPointLinksValidation.ts | 15 +++++++++++++++ src/server/service/links/index.ts | 2 ++ .../visitNationalDataPointLinks.ts | 18 ------------------ 8 files changed, 26 insertions(+), 28 deletions(-) create mode 100644 src/server/service/links/enqueueNationalDataPointLinksValidation.ts delete mode 100644 src/server/worker/tasks/verifyLinks/visitNationalDataPointLinks/visitNationalDataPointLinks.ts diff --git a/src/server/controller/cycleData/links/update.ts b/src/server/controller/cycleData/links/update.ts index adee89ece3..784b33606d 100644 --- a/src/server/controller/cycleData/links/update.ts +++ b/src/server/controller/cycleData/links/update.ts @@ -14,7 +14,6 @@ import { BaseProtocol, DB } from 'server/db/db' import { LinkRepository } from 'server/db/repository/assessmentCycle/links' import { ActivityLogRepository } from 'server/db/repository/public/activityLog' import { LinksService } from 'server/service/links' -import { visitNationalDataPointLinks } from 'server/worker/tasks/verifyLinks/visitNationalDataPointLinks/visitNationalDataPointLinks' type Props = { assessment: Assessment @@ -62,7 +61,7 @@ export const update = async (props: Props): Promise => { ndpUuid, fields: [ndpSection], })) - await visitNationalDataPointLinks({ assessment, countryIso, cycle, targets }) + await LinksService.enqueueNationalDataPointLinksValidation({ assessment, countryIso, cycle, targets }) } return updatedLink diff --git a/src/server/controller/cycleData/nationalDataPoint/remove.ts b/src/server/controller/cycleData/nationalDataPoint/remove.ts index b6449cecd1..7dbc353e12 100644 --- a/src/server/controller/cycleData/nationalDataPoint/remove.ts +++ b/src/server/controller/cycleData/nationalDataPoint/remove.ts @@ -18,8 +18,8 @@ import { MessageTopicRepository } from 'server/db/repository/assessmentCycle/mes import { OriginalDataPointRepository } from 'server/db/repository/assessmentCycle/originalDataPoint' import { ActivityLogRepository } from 'server/db/repository/public/activityLog' import { CountryService } from 'server/service/country' +import { LinksService } from 'server/service/links' import { SocketServer } from 'server/service/socket' -import { visitNationalDataPointLinks } from 'server/worker/tasks/verifyLinks/visitNationalDataPointLinks/visitNationalDataPointLinks' import { updateOriginalDataPointDependentNodes } from './updateDependants/updateOriginalDataPointDependentNodes' @@ -90,7 +90,7 @@ export const remove = async (props: Props, client: BaseProtocol = DB): Promise commentKey === field) - await visitNationalDataPointLinks({ + await LinksService.enqueueNationalDataPointLinksValidation({ assessment, countryIso, cycle, diff --git a/src/server/controller/cycleData/nationalDataPoint/updateDataSources.ts b/src/server/controller/cycleData/nationalDataPoint/updateDataSources.ts index a03a69a42f..3d8e37c804 100644 --- a/src/server/controller/cycleData/nationalDataPoint/updateDataSources.ts +++ b/src/server/controller/cycleData/nationalDataPoint/updateDataSources.ts @@ -12,7 +12,7 @@ import { BaseProtocol, DB } from 'server/db/db' import { DescriptionRepository } from 'server/db/repository/assessmentCycle/descriptions' import { ActivityLogRepository } from 'server/db/repository/public/activityLog' import { CountryService } from 'server/service/country' -import { visitNationalDataPointLinks } from 'server/worker/tasks/verifyLinks/visitNationalDataPointLinks/visitNationalDataPointLinks' +import { LinksService } from 'server/service/links' type Props = { assessment: Assessment @@ -50,7 +50,7 @@ export const updateDataSources = async (props: Props, client: BaseProtocol = DB) await CountryService.updateLastEdit({ assessment, cycle, country, user, lastEditOdp: true, lastUpdateTimestamp }, t) }) - await visitNationalDataPointLinks({ + await LinksService.enqueueNationalDataPointLinksValidation({ assessment, countryIso, cycle, diff --git a/src/server/controller/cycleData/nationalDataPoint/updateYear.ts b/src/server/controller/cycleData/nationalDataPoint/updateYear.ts index f05ca22f84..15b7f7fc9f 100644 --- a/src/server/controller/cycleData/nationalDataPoint/updateYear.ts +++ b/src/server/controller/cycleData/nationalDataPoint/updateYear.ts @@ -13,8 +13,8 @@ import { BaseProtocol, DB } from 'server/db/db' import { OriginalDataPointRepository } from 'server/db/repository/assessmentCycle/originalDataPoint' import { ActivityLogRepository } from 'server/db/repository/public/activityLog' import { CountryService } from 'server/service/country' +import { LinksService } from 'server/service/links' import { SocketServer } from 'server/service/socket' -import { visitNationalDataPointLinks } from 'server/worker/tasks/verifyLinks/visitNationalDataPointLinks/visitNationalDataPointLinks' import { updateOriginalDataPointsDependentNodes } from './updateDependants/updateOriginalDataPointsDependentNodes' @@ -79,7 +79,7 @@ export const updateYear = async (props: Props, client: BaseProtocol = DB): Promi }) // The stored link locations carry the year and a year-based url, so they are refreshed on year change. - await visitNationalDataPointLinks({ + await LinksService.enqueueNationalDataPointLinksValidation({ assessment, countryIso, cycle, diff --git a/src/server/service/links/enqueueNationalDataPointLinksValidation.ts b/src/server/service/links/enqueueNationalDataPointLinksValidation.ts new file mode 100644 index 0000000000..1555f18701 --- /dev/null +++ b/src/server/service/links/enqueueNationalDataPointLinksValidation.ts @@ -0,0 +1,15 @@ +import { Objects } from 'utils/objects' + +import { VerifyLinksJobName } from 'server/worker/tasks/verifyLinks/jobNames' +import { addVerifyLinksJob } from 'server/worker/tasks/verifyLinks/utils/addVerifyLinksJob' +import { VerifyNationalDataPointLinksJobProps } from 'server/worker/tasks/verifyLinks/visitNationalDataPointLinks/props' + +export const enqueueNationalDataPointLinksValidation = async ( + props: VerifyNationalDataPointLinksJobProps +): Promise => { + const { targets } = props + + if (Objects.isEmpty(targets)) return + + await addVerifyLinksJob(VerifyLinksJobName.verifyNationalDataPointLinks, props) +} diff --git a/src/server/service/links/index.ts b/src/server/service/links/index.ts index f1401fd420..d77c1f0e28 100644 --- a/src/server/service/links/index.ts +++ b/src/server/service/links/index.ts @@ -1,7 +1,9 @@ import { enqueueDescriptionLinksValidation } from 'server/service/links/enqueueDescriptionLinksValidation' +import { enqueueNationalDataPointLinksValidation } from 'server/service/links/enqueueNationalDataPointLinksValidation' import { verifyLinks } from 'server/service/links/verifyLinks' export const LinksService = { enqueueDescriptionLinksValidation, + enqueueNationalDataPointLinksValidation, verifyLinks, } diff --git a/src/server/worker/tasks/verifyLinks/visitNationalDataPointLinks/visitNationalDataPointLinks.ts b/src/server/worker/tasks/verifyLinks/visitNationalDataPointLinks/visitNationalDataPointLinks.ts deleted file mode 100644 index a3d9376aa3..0000000000 --- a/src/server/worker/tasks/verifyLinks/visitNationalDataPointLinks/visitNationalDataPointLinks.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { Job } from 'bullmq' - -import { Objects } from 'utils/objects' - -import { VerifyLinksJobName } from 'server/worker/tasks/verifyLinks/jobNames' -import { addVerifyLinksJob } from 'server/worker/tasks/verifyLinks/utils/addVerifyLinksJob' - -import { VerifyNationalDataPointLinksJobProps } from './props' - -export const visitNationalDataPointLinks = async ( - props: VerifyNationalDataPointLinksJobProps -): Promise => { - const { targets } = props - - if (Objects.isEmpty(targets)) return undefined - - return addVerifyLinksJob(VerifyLinksJobName.verifyNationalDataPointLinks, props) -} From a48cffdbcbab58ecf02556ac2e4a017223e2bc2e Mon Sep 17 00:00:00 2001 From: Alejandro Guzman Date: Fri, 24 Jul 2026 10:02:52 -0500 Subject: [PATCH 3/3] 5758 - Rename addVerifyLinksJob to enqueueVerifyLinksJob --- src/server/service/links/enqueueDescriptionLinksValidation.ts | 4 ++-- .../service/links/enqueueNationalDataPointLinksValidation.ts | 4 ++-- .../utils/{addVerifyLinksJob.ts => enqueueVerifyLinksJob.ts} | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) rename src/server/worker/tasks/verifyLinks/utils/{addVerifyLinksJob.ts => enqueueVerifyLinksJob.ts} (94%) diff --git a/src/server/service/links/enqueueDescriptionLinksValidation.ts b/src/server/service/links/enqueueDescriptionLinksValidation.ts index a8137766d1..37d41d2cfc 100644 --- a/src/server/service/links/enqueueDescriptionLinksValidation.ts +++ b/src/server/service/links/enqueueDescriptionLinksValidation.ts @@ -1,7 +1,7 @@ import { Objects } from 'utils/objects' import { VerifyLinksJobName } from 'server/worker/tasks/verifyLinks/jobNames' -import { addVerifyLinksJob } from 'server/worker/tasks/verifyLinks/utils/addVerifyLinksJob' +import { enqueueVerifyLinksJob } from 'server/worker/tasks/verifyLinks/utils/enqueueVerifyLinksJob' import { VerifyDescriptionLinksJobProps } from 'server/worker/tasks/verifyLinks/visitDescriptionLinks/props' export const enqueueDescriptionLinksValidation = async (props: VerifyDescriptionLinksJobProps): Promise => { @@ -9,5 +9,5 @@ export const enqueueDescriptionLinksValidation = async (props: VerifyDescription if (Objects.isEmpty(descriptionIdentifiers)) return - await addVerifyLinksJob(VerifyLinksJobName.verifyDescriptionLinks, props) + await enqueueVerifyLinksJob(VerifyLinksJobName.verifyDescriptionLinks, props) } diff --git a/src/server/service/links/enqueueNationalDataPointLinksValidation.ts b/src/server/service/links/enqueueNationalDataPointLinksValidation.ts index 1555f18701..447db7ba0d 100644 --- a/src/server/service/links/enqueueNationalDataPointLinksValidation.ts +++ b/src/server/service/links/enqueueNationalDataPointLinksValidation.ts @@ -1,7 +1,7 @@ import { Objects } from 'utils/objects' import { VerifyLinksJobName } from 'server/worker/tasks/verifyLinks/jobNames' -import { addVerifyLinksJob } from 'server/worker/tasks/verifyLinks/utils/addVerifyLinksJob' +import { enqueueVerifyLinksJob } from 'server/worker/tasks/verifyLinks/utils/enqueueVerifyLinksJob' import { VerifyNationalDataPointLinksJobProps } from 'server/worker/tasks/verifyLinks/visitNationalDataPointLinks/props' export const enqueueNationalDataPointLinksValidation = async ( @@ -11,5 +11,5 @@ export const enqueueNationalDataPointLinksValidation = async ( if (Objects.isEmpty(targets)) return - await addVerifyLinksJob(VerifyLinksJobName.verifyNationalDataPointLinks, props) + await enqueueVerifyLinksJob(VerifyLinksJobName.verifyNationalDataPointLinks, props) } diff --git a/src/server/worker/tasks/verifyLinks/utils/addVerifyLinksJob.ts b/src/server/worker/tasks/verifyLinks/utils/enqueueVerifyLinksJob.ts similarity index 94% rename from src/server/worker/tasks/verifyLinks/utils/addVerifyLinksJob.ts rename to src/server/worker/tasks/verifyLinks/utils/enqueueVerifyLinksJob.ts index 83b7d77801..945781fce1 100644 --- a/src/server/worker/tasks/verifyLinks/utils/addVerifyLinksJob.ts +++ b/src/server/worker/tasks/verifyLinks/utils/enqueueVerifyLinksJob.ts @@ -19,7 +19,7 @@ type JobPropsByName = { } // Enqueues a verify-links job and makes sure a worker is running to consume it. -export const addVerifyLinksJob = async ( +export const enqueueVerifyLinksJob = async ( jobName: JobName, props: JobPropsByName[JobName] ): Promise => {