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

Fix view licence abs amounts issue plus refactor #1132

Merged
merged 12 commits into from
Jul 1, 2024

Conversation

Cruikshanks
Copy link
Member

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

Part of our work to replace the legacy view licence page

We found our new licence was crashing when we tried to view a specific licence. When we dug into it, the problem was that even though it had a current version in the PermitLicenceModels licenceDataValue field, and that version had purposes, those purposes didn't have abstraction amounts.

It's not common for licences to be in this state, but there is not much we can do as the data comes from NALD. It would have to be corrected there.

So, we need to update the ViewLicenceSummaryPresenter code to handle this. But it has been some time since we built the summary tab so we have more experience with the licence abstraction data. For example, we now know these values can be taken from somewhere other than the JSON blob the previous team was using.

This means, along with fixing the issue, we intend to do a little 'housekeeping' along the way to try and simplify how things are working, and to use normalised data wherever we can.

@Cruikshanks Cruikshanks added bug Something isn't working housekeeping Refactoring, tidying up or other work which supports the project labels Jun 21, 2024
@Cruikshanks Cruikshanks self-assigned this Jun 21, 2024
Cruikshanks added a commit that referenced this pull request Jun 21, 2024
https://eaflood.atlassian.net/browse/WATER-4322
https://eaflood.atlassian.net/browse/WATER-4442

Whilst working on [Fix view licence abs amounts issue plus refactor](#1132) we started making a change to `app/services/licences/fetch-licence-summary.service.js` to bring how it fetches the current licence to be inline with `app/services/return-requirements/setup/fetch-abstraction-data.service.js`.

In both cases, the services that call these are then doing `licence.licenceVersions[0]` in order to access the 'current' one. We could ensure consistency by adding an [Objection.js modifier](https://vincit.github.io/objection.js/api/model/static-properties.html#static-modifiers) to `LicenceModel`. And then we could make it explicit we only care about the current licence (and make everyone's lives easier) if we added a custom [instance method](https://vincit.github.io/objection.js/api/model/instance-methods.html)!

This change does both then updates anything currently handling a current licence version to use them.
Cruikshanks added a commit that referenced this pull request Jun 24, 2024
https://eaflood.atlassian.net/browse/WATER-4322
https://eaflood.atlassian.net/browse/WATER-4442

Whilst working on [Fix view licence abs amounts issue plus refactor](#1132) we started making a change to `app/services/licences/fetch-licence-summary.service.js` to bring how it fetches the current licence to be in line with `app/services/return-requirements/setup/fetch-abstraction-data.service.js`.

In both cases, the services that call these are then doing `licence.licenceVersions[0]` in order to access the 'current' one. We could ensure consistency by adding an [Objection.js modifier](https://vincit.github.io/objection.js/api/model/static-properties.html#static-modifiers) to `LicenceModel`. And then we could make it explicit that we only care about the current licence (and make everyone's lives easier) if we added a custom [instance method](https://vincit.github.io/objection.js/api/model/instance-methods.html)!

This change does both then updates anything currently handling a current licence version to use them.
@Cruikshanks Cruikshanks force-pushed the simplify-licence-summary branch from 1130a92 to 042d92b Compare June 24, 2024 14:49
https://eaflood.atlassian.net/browse/WATER-4322

> Part of our work to replace the legacy view licence page

We found our new licence was crashing when we tried to view a specific licence. When we dug into it the problem was that even though it had a current version in the `PermitLicenceModel`s `licenceDataValue` field, and that version had purposes, those purposes didn't have abstraction amounts.

It's not common for licences to be in this state, but there is not much we can do as the data comes from NALD. It would have to be corrected there.

So, we need to update the `ViewLicenceSummaryPresenter` code to handle. But it has been some time since we built the summary tab so we have more experience with the licence abstraction data. We now know these values can be taken from somewhere other than the JSON blob the previous team were using.

This means along with fixing the issue, we intend to do a little 'housekeeping' along the way to try and simplify how things are working and to use normalised data wherever we can.
Now matches the fact we expect multiple values back and the variable name.
There is no real need for these to be determined inside the abstraction wrapper. They can handled like other properties and the methods can be called directly.
We can take these off the licence version purposes which means we can drop having to extract them from the permit licence first. We also set them directly in function and remove the element from the `_abstractionWrapper()`.
@Cruikshanks Cruikshanks force-pushed the simplify-licence-summary branch from 20f57ec to e6ca170 Compare June 30, 2024 19:25
@Cruikshanks Cruikshanks marked this pull request as ready for review July 1, 2024 06:56
@Cruikshanks Cruikshanks merged commit 9903139 into main Jul 1, 2024
6 checks passed
@Cruikshanks Cruikshanks deleted the simplify-licence-summary branch July 1, 2024 06:57
Cruikshanks added a commit that referenced this pull request Jul 1, 2024
https://eaflood.atlassian.net/browse/WATER-4331

> Part of the work to replace the legacy view licence page

After attempting to [simplify the logic that builds the view licence page's summary tab](#1132) we've spotted that we may have introduced a bug.

We have found a licence that has been linked to the same gauging station multiple times. This results in seeing the same station listed multiple times in the summary.

Like the other sections, where something is duplicated we should see only one entry. This change fixes the logic and ensures the list is distinct.
Cruikshanks added a commit that referenced this pull request Jul 2, 2024
https://eaflood.atlassian.net/browse/WATER-4331

> Part of the work to replace the legacy view licence page

After attempting to [simplify the logic that builds the view licence page's summary tab](#1132) we've spotted that we may have introduced a bug.

We have found a licence that has been linked to the same gauging station multiple times. This results in seeing the same station listed multiple times in the summary.

Like the other sections, where something is duplicated, we should see only one entry. This change fixes the logic and ensures the list is distinct.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working 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