-
Notifications
You must be signed in to change notification settings - Fork 2
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 new licence changes table #2666
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://eaflood.atlassian.net/browse/WATER-4546 > Part of the work to migrate management of return versions to WRLS from NALD During the import from NALD, if a licence end date is changed, for example, it has been revoked in NALD our return versions functionality needs to know about it. This is so we can reissue the return logs for the licence in order to match the changed end date. We are actively trying to move away from the legacy code base, so this work was always going to be done in [water-abstraction-system](https://github.com/DEFRA/water-abstraction-system). Initially, it was going to be triggered by our [own import process that was due to replace the legacy one](https://eaflood.atlassian.net/browse/WATER-4535). But that was when we thought ReSP would be taking over from NALD. Now the plan is WRLS will encompass the final abstraction leg and takeover from NALD. There is little point in replacing a complex import we intend to switch off in the next year. But, knowing we'd need something in the interim we created the `/jobs/licence-changes` job in **water-abstraction-system**. The intent was to schedule this after the first NALD import job had completed (that one that downloads and extracts the NALD data), but before the main licence import job. That way our job could compare the NALD and WRLS licence records in order to determine if an end date has changed. But then we had our 'doh!' moment. Our reissue return logs engine expects to be given a licence ID and date the change applies. But it needs the WRLS licence record to have been updated in order to determine what the new return logs start and end dates should be. If we schedule `/jobs/licence-changes` before the licence import job, it will see the change but won't reissue anything because the WRLS record won't have been updated. If we schedule it after, it won't see any different so won't trigger the reissue. Doh! So, we've needed to completely change tact on this. Now we intend to - _trigger_ `/jobs/licence-changes` (though we'll move the it to a different endpoint as it will no longer be a job) from the [water-abstraction-import](https://github.com/DEFRA/water-abstraction-import) NALD import job rather than schedule it - update `/jobs/licence-changes` to store the details of changed licences in a new table - add a new endpoint that processes these 'licence change' records, and which can be triggered from the **water-abstraction-import** main licence import job This change is needed to create the new table in the `water` schema.
Doh! The different might be that a date has now been set in NALD, but WRLS is null, or vice versa. Therefore we need to be able to store null for the dates in the table.
Cruikshanks
added a commit
to DEFRA/water-abstraction-system
that referenced
this pull request
Jan 6, 2025
https://eaflood.atlassian.net/browse/WATER-4546 > Part of the work to migrate management of return versions to WRLS from NALD During the import from NALD, if a licence end date is changed, for example, if it has been revoked in NALD, our return version functionality needs to know about it. This is so we can reissue the return logs for the licence to match the changed end date. We are actively trying to move away from the legacy code base, so this work was always going to be done in here. Initially, it would be triggered by our [own import process](https://eaflood.atlassian.net/browse/WATER-4535), which was due to replace the legacy one. But that was when we thought ReSP would be taking over from NALD. Now, the plan is for WRLS to encompass the final abstraction leg and take over from NALD. There is little point in replacing a complex import we intend to switch off in the next year. But, knowing we'd need something in the interim, we created the [/jobs/licence-changes job](#1593). The intent was to schedule this after the first [NALD import job](https://github.com/DEFRA/water-abstraction-team/blob/main/jobs/import.md#nald-import) had completed (the one that downloads and extracts the NALD data) but before the main [licence import job](https://github.com/DEFRA/water-abstraction-team/blob/main/jobs/import.md#licence-import). That way, our job could compare the NALD and WRLS licence records to determine if an end date has changed. But then we had our 'doh!' moment. Our reissue return logs engine expects to be given a licence ID and the date the change applies. However, the WRLS licence record needs to have been updated for it to determine the start and end dates of the new return logs. If we schedule `/jobs/licence-changes` before the licence import job, it will see the change but won't reissue anything because the WRLS record won't have been updated. If we schedule it after, it won't see any difference and won't trigger the reissue. Doh! So, we've needed to change tact on this completely. Now, we intend to - _trigger_ `/licences/end-dates/check` from the [NALD import job](https://github.com/DEFRA/water-abstraction-team/blob/main/jobs/import.md#nald-import) rather than schedule it - refactor `/jobs/licence-changes` as `/licences/end-dates`, but instead of processing changed licences it [stores the details of the change in a table](DEFRA/water-abstraction-service#2666) - add a new `/licences/end-dates/process` endpoint that processes these 'licence change' records, and which will be triggered from the [licence import job](https://github.com/DEFRA/water-abstraction-team/blob/main/jobs/import.md#licence-import) This change handles the refactoring and creating of the endpoints, plus addition of a new model for for the new table.
This will support the event that the check is performed a second time before the WRLS record has been updated, or the end date change process has had a chance to run. If the `/licences/end-date/check` process flags the same licence again, for the same date type, we can use the constraint to apply an Upsert query and update the dates to the latest information. This avoids us erroring if we attempt to insert the record for a second time.
Forgot to add this when creating the table. Our code in water-abstraction-system, having identified what date change needs to be captured, also determines what change date to use, for example, if 2 dates have been updated at the same time. We need this to be able to process the change in our later process.
Cruikshanks
added a commit
to DEFRA/water-abstraction-import
that referenced
this pull request
Jan 7, 2025
https://eaflood.atlassian.net/browse/WATER-4546 > Part of the work to migrate management of return versions to WRLS from NALD During the import from NALD, if a licence end date is changed, for example, if it has been revoked in NALD, our return version functionality needs to know about it. This is so we can reissue the return logs for the licence to match the changed end date. We are actively trying to move away from the legacy code base, so this work was always going to be done in [water-abstraction-system](https://github.com/DEFRA/water-abstraction-system). Initially, it would be triggered by our [own import process](https://eaflood.atlassian.net/browse/WATER-4535), which was due to replace the legacy one. But that was when we thought ReSP would be taking over from NALD. Now, the plan is for WRLS to encompass the final abstraction leg and take over from NALD. So, there is little point in replacing a complex import we intend to switch off in the next year. But, knowing we'd need something in the interim, we created the [/jobs/licence-changes job](DEFRA/water-abstraction-system#1593). The intent was to schedule this after the first [NALD import job](https://github.com/DEFRA/water-abstraction-team/blob/main/jobs/import.md#nald-import) had completed (the one that downloads and extracts the NALD data) but before the main [licence import job](https://github.com/DEFRA/water-abstraction-team/blob/main/jobs/import.md#licence-import). That way, our job could compare the NALD and WRLS licence records to determine if an end date has changed. But then we had our 'doh!' moment. Our reissue return logs engine expects to be given a licence ID and the date the change applies. However, the WRLS licence record needs to have been updated for it to determine the start and end dates of the new return logs. If we schedule `/jobs/licence-changes` before the licence import job, it will see the change but won't reissue anything because the WRLS record won't have been updated. If we schedule it after, it won't see any difference and won't trigger the reissue. Doh! So, we've needed to change tact on this completely. Now, we intend to - _trigger_ `/licences/end-dates/check` from the [NALD import job](https://github.com/DEFRA/water-abstraction-team/blob/main/jobs/import.md#nald-import) rather than schedule it - refactor `/jobs/licence-changes` as `/licences/end-dates`, but instead of processing changed licences, it [stores the details of the change in a table](DEFRA/water-abstraction-service#2666) - add a new `/licences/end-dates/process` endpoint that processes these 'licence change' records, which will be triggered from the [licence import job](https://github.com/DEFRA/water-abstraction-team/blob/main/jobs/import.md#licence-import) This change adds new steps to the NALD and Licence import jobs to trigger these new endpoints.
Cruikshanks
added a commit
to DEFRA/water-abstraction-import
that referenced
this pull request
Jan 7, 2025
https://eaflood.atlassian.net/browse/WATER-4546 > Part of the work to migrate management of return versions to WRLS from NALD During the import from NALD, if a licence end date is changed, for example, if it has been revoked in NALD, our return version functionality needs to know about it. This is so we can reissue the return logs for the licence to match the changed end date. We are actively trying to move away from the legacy code base, so this work was always going to be done in [water-abstraction-system](https://github.com/DEFRA/water-abstraction-system). Initially, it would be triggered by our [own import process](https://eaflood.atlassian.net/browse/WATER-4535), which was due to replace the legacy one. But that was when we thought ReSP would be taking over from NALD. Now, the plan is for WRLS to encompass the final abstraction leg and take over from NALD. So, there is little point in replacing a complex import we intend to switch off in the next year. But, knowing we'd need something in the interim, we created the [/jobs/licence-changes job](DEFRA/water-abstraction-system#1593). The intent was to schedule this after the first [NALD import job](https://github.com/DEFRA/water-abstraction-team/blob/main/jobs/import.md#nald-import) had completed (the one that downloads and extracts the NALD data) but before the main [licence import job](https://github.com/DEFRA/water-abstraction-team/blob/main/jobs/import.md#licence-import). That way, our job could compare the NALD and WRLS licence records to determine if an end date has changed. But then we had our 'doh!' moment. Our reissue return logs engine expects to be given a licence ID and the date the change applies. However, the WRLS licence record needs to have been updated for it to determine the start and end dates of the new return logs. If we schedule `/jobs/licence-changes` before the licence import job, it will see the change but won't reissue anything because the WRLS record won't have been updated. If we schedule it after, it won't see any difference and won't trigger the reissue. Doh! So, we've needed to change tact on this completely. Now, we intend to - _trigger_ `/licences/end-dates/check` from the [NALD import job](https://github.com/DEFRA/water-abstraction-team/blob/main/jobs/import.md#nald-import) rather than schedule it - refactor `/jobs/licence-changes` as `/licences/end-dates`, but instead of processing changed licences, it [stores the details of the change in a table](DEFRA/water-abstraction-service#2666) - add a new `/licences/end-dates/process` endpoint that processes these 'licence change' records, which will be triggered from the [licence import job](https://github.com/DEFRA/water-abstraction-team/blob/main/jobs/import.md#licence-import) This change adds new steps to the NALD and Licence import jobs to trigger these new endpoints.
Cruikshanks
added a commit
to DEFRA/water-abstraction-system
that referenced
this pull request
Jan 7, 2025
https://eaflood.atlassian.net/browse/WATER-4546 > Part of the work to migrate management of return versions to WRLS from NALD During the import from NALD, if a licence end date is changed, for example, if it has been revoked in NALD, our return version functionality needs to know about it. This is so we can reissue the return logs for the licence to match the changed end date. We are actively trying to move away from the legacy code base, so this work was always going to be done in here. Initially, it would be triggered by our [own import process](https://eaflood.atlassian.net/browse/WATER-4535), which was due to replace the legacy one. But that was when we thought ReSP would be taking over from NALD. Now, the plan is for WRLS to encompass the final abstraction leg and take over from NALD. There is little point in replacing a complex import we intend to switch off in the next year. But, knowing we'd need something in the interim, we created the [/jobs/licence-changes job](#1593). The intent was to schedule this after the first [NALD import job](https://github.com/DEFRA/water-abstraction-team/blob/main/jobs/import.md#nald-import) had completed (the one that downloads and extracts the NALD data) but before the main [licence import job](https://github.com/DEFRA/water-abstraction-team/blob/main/jobs/import.md#licence-import). That way, our job could compare the NALD and WRLS licence records to determine if an end date has changed. But then we had our 'doh!' moment. Our reissue return logs engine expects to be given a licence ID and the date the change applies. However, the WRLS licence record needs to have been updated for it to determine the start and end dates of the new return logs. If we schedule `/jobs/licence-changes` before the licence import job, it will see the change but won't reissue anything because the WRLS record won't have been updated. If we schedule it after, it won't see any difference and won't trigger the reissue. Doh! So, we've needed to change tact on this completely. Now, we intend to - _trigger_ `/licences/end-dates/check` from the [NALD import job](https://github.com/DEFRA/water-abstraction-team/blob/main/jobs/import.md#nald-import) rather than schedule it - refactor `/jobs/licence-changes` as `/licences/end-dates`, but instead of processing changed licences, it [stores the details of the change in a table](DEFRA/water-abstraction-service#2666) - add a new `/licences/end-dates/process` endpoint that processes these 'licence change' records, which will be triggered from the [licence import job](https://github.com/DEFRA/water-abstraction-team/blob/main/jobs/import.md#licence-import) This change handles the refactoring and creation of the endpoints, plus the addition of a new model for the new table.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
https://eaflood.atlassian.net/browse/WATER-4546
During the import from NALD, if a licence end date is changed, for example, if it has been revoked in NALD, our return version functionality needs to know about it. This is so we can reissue the return logs for the licence to match the changed end date.
We are actively trying to move away from the legacy code base, so this work was always going to be done in water-abstraction-system. Initially, it would be triggered by our own import process due to replace the legacy one. But that was when we thought ReSP would be taking over from NALD.
Now, the plan is for WRLS to encompass the final abstraction leg and take over from NALD. There is little point in replacing a complex import we intend to switch off in the next year.
But, knowing we'd need something in the interim, we created the /jobs/licence-changes job. The intent was to schedule this after the first NALD import job had completed (the one that downloads and extracts the NALD data) but before the main licence import
job. That way, our job could compare the NALD and WRLS licence records to determine if an end date has changed.
But then we had our 'doh!' moment.
Our reissue return logs engine expects to be given a licence ID and the date the change applies. However, the WRLS licence record needs to have been updated for it to determine the start and end dates of the new return logs.
If we schedule
/jobs/licence-changes
before the licence import job, it will see the change but won't reissue anything because the WRLS record won't have been updated. If we schedule it after, it won't see any difference and won't trigger the reissue.Doh!
So, we've needed to change tact on this completely. Now, we intend to
/jobs/licence-changes
(though we'll move it to a different endpoint as it will no longer be a job) from the NALD import job rather than schedule it/jobs/licence-changes
to store the details of changed licences in a new tableThis change is needed to create the new table in the
water
schema.