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 base point model with a describe helper #1289

Merged
merged 7 commits into from
Aug 29, 2024
Merged

Conversation

Cruikshanks
Copy link
Member

https://eaflood.atlassian.net/browse/WATER-4645

Part of the work to migrate return versions from NALD to WRLS

Context

We've been extending and amending the import of return versions from NALD to WRLS as part of our work to switch from NALD to WRLS to manage them. To support this, we Created a return-requirement-points table and updated the import to import them point details.

Users select these points as part of the return requirements setup journey we've built. We currently extract them from the JSON blob stored in the permit.licence table. However, the import service only populates the points for licences.

  • That have not ended
  • That have a current licence version

Otherwise, permit.licence is not populated with the points data our journey relies on, causing it to throw an error. Places like the view licence page are also affected by this.

For example, it is perfectly valid that we have an 'ended' licence that we need to correct the historic return versions. And no matter the state, we can see what points the licence was linked to.

Thanks to this change in water-abstraction-import we are now importing them to a new table in the water schema. And with Add Licence Version Purpose Point model we enabled access to the data via Objection.js.

Change

Depending on the detail in a 'point', it needs to be described in 3 different ways.

  • when a single grid reference as a point
  • when two grid references as a reach
  • when four grid references as an area

A point can only have 1, 2 or 4 grid references, never 3!

We already have so many places in this repo where we need to work this out that we have a general helper method (generateAbstractionPointDetail() in app/lib/general.lib.js). This will become defunct, however, when we start pulling the data using our new LicenceVersionPurposePointModel.

We already have a pattern for models that contain data that needs to be interpreted in a certain way, such as the contact name in ContactModel and the licence holder in LicenceModel.

The slight difference is that we now have two models that need the same ability. So, this change will introduce a new BasePointModel that the existing ReturnRequirementPointModel and LicenceVersionPurposePointModel will extend. On the new BasePointModel, we'll add the Objection.js instance function $describe(), which will interpret the point data and determine what description to use.

In later changes, we'll start updating the repo to use the new helper and model rather than the old one.

https://eaflood.atlassian.net/browse/WATER-4645

> Part of the work to migrate return versions from NALD to WRLS

**Context**

We've been extending and amending the import of return versions from NALD to WRLS as part of our work to switch from NALD to WRLS to manage them. To support this we [Created a return-requirement-points table](DEFRA/water-abstraction-service#2540) and [updated the import](DEFRA/water-abstraction-import#933) to import them point details.

Users select these points as part of the return requirements setup journey we've built. We currently extract them from the JSON blob stored in the `permit.licence` table. The problem we've encountered is the import service only populates the points for licences that.

- Have not ended
- Have a current licence version

Otherwise, `permit.licence` is not populated with the points data our journey relies on, causing it to throw an error. Places like the view licence page are also affected by this.

For example, it is perfectly valid that we have an 'ended' licence that we need to correct the historic return versions. And no matter the state, we can see what points the licence was linked to.

Thanks to [this change in water-abstraction-import we are now importing them](DEFRA/water-abstraction-import#1009) to a [new table in the `water` schema](DEFRA/water-abstraction-service#2626). And with [Add Licence Version Purpose Point model](#1288) we enabled access to the data via [Objection.js](https://vincit.github.io/objection.js/).

**Change**

Depending on the detail in a 'point' it needs to be described in 3 different ways.

- when a single grid reference as a _point_
- when two grid references as a _reach_
- when four grid references as an _area_

> A point can only have 1, 2 or 4 grid references, never 3!

We already have so many places in this repo where we need to work this out that we have a general helper method (`generateAbstractionPointDetail()` in `app/lib/general.lib.js`) to do it. This will become defunct, however, when we start pulling the data using our new `LicenceVersionPurposePointModel`.

We already have a pattern for models that contain data that needs to be interpreted in a certain way, for example, contact name in `ContactModel` and licence holder in `LicenceModel`.

The slight difference is we now have _two_ models that need the same ability. So, this change will introduce a new `BasePointModel` that the existing `ReturnRequirementPointModel` and `LicenceVersionPurposePointModel` will extend. On the new `BasePointModel` we'll add the Objection.js instance function `$describe()` that will do the work of interpreting the point data and determining what description to use.

> In later changes we'll start updating the repo to use the new helper and model rather than the old one.
@Cruikshanks Cruikshanks added the housekeeping Refactoring, tidying up or other work which supports the project label Aug 28, 2024
@Cruikshanks Cruikshanks self-assigned this Aug 28, 2024
Where we currently have a 'point' based model we can demonstrate using the `$describe()` function instead of the general lib version.

And, as this was the only thing using it we can delete the general lib version!
@Cruikshanks Cruikshanks marked this pull request as ready for review August 29, 2024 19:39
@Cruikshanks Cruikshanks merged commit c28f58e into main Aug 29, 2024
6 checks passed
@Cruikshanks Cruikshanks deleted the add-base-point-model branch August 29, 2024 19:39
Cruikshanks added a commit that referenced this pull request Sep 2, 2024
https://eaflood.atlassian.net/browse/WATER-4600
https://eaflood.atlassian.net/browse/WATER-4645

> Part of the work to migrate return versions from NALD to WRLS

We've been extending and amending the import of return versions from NALD to WRLS as part of our work to switch from NALD to WRLS to manage them. To support this, we [Created a return-requirement-points table](DEFRA/water-abstraction-service#2540) and [updated the import](DEFRA/water-abstraction-import#933) to import them point details.

Users select these points as part of the return requirements setup journey we've built. We currently extract them from the JSON blob stored in the `permit.licence` table. However, the import service only populates the points for licences.

- That have not ended
- That have a current licence version

Otherwise, `permit.licence` is not populated with the points data our journey relies on, causing it to throw an error.

In [Add Licence Version Purpose Point model](#1288) to allow us to access the data. The in [Add base point model with a describe helper](#1289) we extended the models to hand how to describe a point.

With all this in place, we can now get back to updating the return requirements setup journey to source 'points' from the new table. This will fix the issue we currently have with it and get it working for all licences again.

The fix requires

- updating the 'use abstraction data' journey to pull points from the new table
- updating the 'manual journey' to pull points from the new table

We'll also update the 'copy from existing' journey to use the new features of the `BasePointModel` rather than the general lib helper.
Cruikshanks added a commit that referenced this pull request Sep 4, 2024
https://eaflood.atlassian.net/browse/WATER-4600
https://eaflood.atlassian.net/browse/WATER-4645

> Part of the work to migrate return versions from NALD to WRLS

We've been extending and amending the import of return versions from NALD to WRLS as part of our work to switch from NALD to WRLS to manage them. To support this, we [Created a return-requirement-points table](DEFRA/water-abstraction-service#2540) and [updated the import](DEFRA/water-abstraction-import#933) to import them point details.

Users select these points as part of the return requirements setup journey we've built. We currently extract them from the JSON blob stored in the `permit.licence` table. However, the import service only populates the points for licences.

- That have not ended
- That have a current licence version

Otherwise, `permit.licence` is not populated with the points data our journey relies on, causing it to throw an error.

In [Add Licence Version Purpose Point model](#1288) to allow us to access the data. The in [Add base point model with a describe helper](#1289) we extended the models to hand how to describe a point.

With all this in place, we can now get back to updating the return requirements setup journey to source 'points' from the new table. This will fix the issue we currently have with it and get it working for all licences again.

The fix requires

- updating the 'use abstraction data' journey to pull points from the new table
- updating the 'manual journey' to pull points from the new table

We'll also update the 'copy from existing' journey to use the new features of the `BasePointModel` rather than the general lib helper.
Cruikshanks added a commit that referenced this pull request Sep 6, 2024
https://eaflood.atlassian.net/browse/WATER-4600
https://eaflood.atlassian.net/browse/WATER-4645

> Part of the work to migrate return versions from NALD to WRLS

We've been extending and amending the import of return versions from NALD to WRLS as part of our work to switch from NALD to WRLS to manage them. To support this, we [Created a return-requirement-points table](DEFRA/water-abstraction-service#2540) and [updated the import](DEFRA/water-abstraction-import#933) to import them point details.

Users select these points as part of the return requirements setup journey we've built. We currently extract them from the JSON blob stored in the `permit.licence` table. However, the import service only populates the points for licences.

- That have not ended
- That have a current licence version

Otherwise, `permit.licence` is not populated with the points data our journey relies on, causing it to throw an error.

So, we needed another source for points. In [Start importing licence version points to 'water'](DEFRA/water-abstraction-import#1009) we updated the **water-abstraction-import** to start importing licence version purpose points to a new table.

We added the model to access the data in [Add Licence Version Purpose Point model](#1288). In [Add base point model with a describe helper](#1289), we extended the models to show how to describe a point.

With all this in place, we can now update the return requirements setup journey to source 'points' from the new table. This will fix the issue we currently have with it and get it working again for all licences.

The fix requires

- updating the 'use abstraction data' journey to pull points from the new table
- updating the 'manual journey' to pull points from the new table

We'll also update the 'copy from existing' journey to use the new features of the `BasePointModel` rather than the general lib helper.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
housekeeping Refactoring, tidying up or other work which supports the project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant