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

Refactor the import legacy persist logic #1387

Merged
merged 25 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
4c01d51
Refactor the import legacy persist logic
jonathangoulding Oct 7, 2024
aa47f0c
chore: remove only in test
jonathangoulding Oct 7, 2024
02f4299
chore: fix missing file extensions
jonathangoulding Oct 7, 2024
37ec675
Merge branch 'main' into refactor-import-legacy-persist-logic
jonathangoulding Oct 7, 2024
8f3295e
chore: update docs
jonathangoulding Oct 7, 2024
cd512c5
refactor: test into separate folders
jonathangoulding Oct 7, 2024
5ac72f0
refactor: test into separate folders
jonathangoulding Oct 7, 2024
1596c5f
chore: pre pr checks
jonathangoulding Oct 7, 2024
b4e3ee7
Merge branch 'main' into refactor-import-legacy-persist-logic
jonathangoulding Oct 7, 2024
a83fd3d
chore: fix js docs
jonathangoulding Oct 8, 2024
3f0685f
test: update persist import service
jonathangoulding Oct 8, 2024
5462a5e
chore: pre pr checks
jonathangoulding Oct 8, 2024
b7ceade
Merge branch 'main' into refactor-import-legacy-persist-logic
jonathangoulding Oct 9, 2024
cd5734d
Merge branch 'main' into refactor-import-legacy-persist-logic
jonathangoulding Oct 9, 2024
eae2998
Merge branch 'main' into refactor-import-legacy-persist-logic
jonathangoulding Oct 10, 2024
a396a09
Update test/services/import/legacy/process-licence.service.test.js
jonathangoulding Oct 10, 2024
586183d
Update app/services/import/legacy/process-licence.service.js
jonathangoulding Oct 10, 2024
c783582
Update app/services/import/persist/persist-company.service.js
jonathangoulding Oct 10, 2024
814b9df
Update app/services/import/persist-import.service.js
jonathangoulding Oct 10, 2024
c71ced3
Update app/services/import/persist/persist-licence-versions.service.js
jonathangoulding Oct 10, 2024
e740f34
chore: fix pr issues
jonathangoulding Oct 10, 2024
a9ae425
chore: fix pr issues
jonathangoulding Oct 10, 2024
4321c9a
Merge branch 'main' into refactor-import-legacy-persist-logic
jonathangoulding Oct 10, 2024
5e73757
Merge branch 'main' into refactor-import-legacy-persist-logic
jonathangoulding Oct 11, 2024
5a0fab4
Merge branch 'main' into refactor-import-legacy-persist-logic
jonathangoulding Oct 11, 2024
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
2 changes: 1 addition & 1 deletion app/services/import/legacy/process-licence.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

const LicenceStructureValidator = require('../../../validators/import/licence-structure.validator.js')
const PersistLicenceService = require('../persist-licence.service.js')
const PersistLicenceService = require('../persist-import.service.js')
jonathangoulding marked this conversation as resolved.
Show resolved Hide resolved
const ProcessLicenceReturnLogsService = require('../../jobs/return-logs/process-licence-return-logs.service.js')
const TransformAddressesService = require('./transform-addresses.service.js')
const TransformCompanyAddressesService = require('./transform-company-addresses.service.js')
Expand Down
38 changes: 38 additions & 0 deletions app/services/import/persist-import.service.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
'use strict'

/**
* Creates or updates an imported licence and its child entities that have been transformed and validated
* @module PersistImportService
*/

const PersistImportService = require('./persist/persist-licence.service.js')
jonathangoulding marked this conversation as resolved.
Show resolved Hide resolved
const PersistLicenceVersionsService = require('./persist/persist-licence-versions.service.js')
const PersistCompanyService = require('./persist/persist-company.service.js')
const LicenceModel = require('../../models/licence.model.js')
const { timestampForPostgres } = require('../../lib/general.lib.js')

/**
* Creates or updates an imported licence and its child entities that have been transformed and validated
*
* @param {object} transformedLicence - An object representing a valid WRLS licence
* @param {object[]} transformedCompanies - an array of companies representing a WRLS company
*
* @returns {Promise<object>}
*/
async function go (transformedLicence, transformedCompanies) {
return LicenceModel.transaction(async (trx) => {
const updatedAt = timestampForPostgres()

const id = await PersistImportService.go(trx, updatedAt, transformedLicence)

await PersistLicenceVersionsService.go(trx, updatedAt, transformedLicence, id)

await PersistCompanyService.go(trx, updatedAt, transformedCompanies)

return id
})
}

module.exports = {
go
}
257 changes: 0 additions & 257 deletions app/services/import/persist-licence.service.js

This file was deleted.

Loading
Loading