Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add wlrs licence id to the nald licence import #1319

Merged
merged 1 commit into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion app/services/import/legacy/fetch-licence.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,14 @@ function _query () {
AND nalv."AABL_ID" = nal."ID"
AND nalv."STATUS" <> 'DRAFT'
) AS earliest_version_start_date,
r.id AS region_id
r.id AS region_id,
l.id as wrls_licence_id
FROM
"import"."NALD_ABS_LICENCES" nal
LEFT JOIN
public.regions r ON r.nald_region_id = (nal."FGAC_REGION_CODE")::INTEGER
LEFT JOIN
public.licences l ON l.licence_ref = nal."LIC_NO"
WHERE
nal."LIC_NO" = ?;
`
Expand Down Expand Up @@ -98,4 +101,5 @@ module.exports = {
* @property {Date} revoked_date
* @property {Date} earliest_version_start_date
* @property {string} region_id
* @property {uuid} wrls_licence_id - licence id used to determine if a licence already exists in WRLS
*/
7 changes: 6 additions & 1 deletion app/services/import/legacy/process-licence.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ async function go (licenceRef) {
const startTime = currentTimeInNanoseconds()

// Transform the parent legacy licence record first
const { naldLicenceId, regionCode, transformedLicence } = await TransformLicenceService.go(licenceRef)
const { naldLicenceId, regionCode, transformedLicence, wrlsLicenceId } =
await TransformLicenceService.go(licenceRef)

// Pass the transformed licence through each transformation step, building the licence as we go
await TransformLicenceVersionsService.go(regionCode, naldLicenceId, transformedLicence)
Expand All @@ -42,6 +43,10 @@ async function go (licenceRef) {
// Either insert or update the licence in WRLS
const licenceId = await PersistLicenceService.go(transformedLicence, transformedCompanies)

if (wrlsLicenceId) {
// Process mod logs
}

calculateAndLogTimeTaken(startTime, 'Legacy licence import complete', { licenceId, licenceRef })
} catch (error) {
global.GlobalNotifier.omfg('Legacy licence import errored', { licenceRef }, error)
Expand Down
3 changes: 2 additions & 1 deletion app/services/import/legacy/transform-licence.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ async function go (licenceRef) {
return {
naldLicenceId: naldLicence.id,
regionCode: naldLicence.region_code,
transformedLicence
transformedLicence,
wrlsLicenceId: naldLicence.wrls_licence_id
}
}

Expand Down
Loading