diff --git a/src/server/controller/cycleData/links/update.ts b/src/server/controller/cycleData/links/update.ts
index a048154d80..784b33606d 100644
--- a/src/server/controller/cycleData/links/update.ts
+++ b/src/server/controller/cycleData/links/update.ts
@@ -13,8 +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 { visitNationalDataPointLinks } from 'server/worker/tasks/verifyLinks/visitNationalDataPointLinks/visitNationalDataPointLinks'
+import { LinksService } from 'server/service/links'
type Props = {
assessment: Assessment
@@ -51,7 +50,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.
@@ -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/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..37d41d2cfc
--- /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 { enqueueVerifyLinksJob } from 'server/worker/tasks/verifyLinks/utils/enqueueVerifyLinksJob'
+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 enqueueVerifyLinksJob(VerifyLinksJobName.verifyDescriptionLinks, props)
+}
diff --git a/src/server/service/links/enqueueNationalDataPointLinksValidation.ts b/src/server/service/links/enqueueNationalDataPointLinksValidation.ts
new file mode 100644
index 0000000000..447db7ba0d
--- /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 { enqueueVerifyLinksJob } from 'server/worker/tasks/verifyLinks/utils/enqueueVerifyLinksJob'
+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 enqueueVerifyLinksJob(VerifyLinksJobName.verifyNationalDataPointLinks, props)
+}
diff --git a/src/server/service/links/index.ts b/src/server/service/links/index.ts
index 2e3c65bf64..d77c1f0e28 100644
--- a/src/server/service/links/index.ts
+++ b/src/server/service/links/index.ts
@@ -1,5 +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/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 => {
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)
-}
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)
-}