Skip to content

Commit

Permalink
Update the 'points' data solution
Browse files Browse the repository at this point in the history
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

In [Add Licence Version Purpose Point model](#1288) we added our second model that represented a table in the `water` schema that hold point information. When we added `ReturnRequirementPointModel` it was to represent points linked to a return requirement.

In the setup journey for new return requirements you select the points to associate from those against the licence. We were extracting this information from the `permit.licence` table until we realised that [water-abstraction-import](https://github.com/DEFRA/water-abstraction-import) does not populate it when a licence is 'dead'.

We need to be able to create new return requirements even for dead licences in order to correct historic information. So, this source being defunct we made changes to the import to populate a new `water.licence_version_purpose_points` from which we could then derive a licence's points.

That worked great for returns setup, so we moved to updating the view licence summary page to use the new source. It also was effected by the issue that point information was no longer available if the licence was dead. The page includes information about the water source for a licence. It was then we realised that the water source is derived from a licence's points!

What we'd built for return requirements and licence version purposes was missing this information.

We investigated the NALD data properly and came away with some realisations

- NALD maintains a central list of 'points' (we knew this, but like addresses felt this was unnecessary)
- Each point holds a lot more data than just the National Grid References for its location
- Each NALD point is linked to a NALD source, and these too hold extra information

There was extra information users were maintaining against each point that we were missing. This information explained why points were centrally managed and other records were linked to them. This realisation meant we needed to completely re-think how we should maintain points in WRLS going forward.

So, in [the water-abstraction-service](DEFRA/water-abstraction-service#2638) we've created a migration to add new `sources` and `points` tables. We'also amended the existing `licence_version_purpose_points` and `return_requirement_points` to make it possible to link them to `points`. (Their `ngr_*` fields plus things like `description` are now defunct but to avoid breaking changes we'll need to drop them in a future change.)

In [water-abstraction-import](DEFRA/water-abstraction-import#1028) we've added a new job to ensure `points` gets populated as part of the import. We've also incorporated populating and linking `licence_version_purpose_points` and `return_requirement_points` as part of the new job.

With those changes in place, this change updates everything around the existing point models, as well as adding the new ones.

The water sources are reference data, so as part of adding `SourceModel` we include a seeder. The existing models and their tests are updated to represent the fact they are now just `many-to-many` models. This means we make `points` a top level property of `ReturnRequirementModel` and `LicenceVersionPurposeModel`.

The logic for describing a point is copied to `PointModel`. We'll delete `BasePointModel` in the next change, where we update the existing functionality to use the new structure.
  • Loading branch information
Cruikshanks committed Sep 24, 2024
1 parent 047af3d commit a680861
Showing 0 changed files with 0 additions and 0 deletions.

0 comments on commit a680861

Please sign in to comment.