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

Replace rtn vers mod log import with all versions #998

Merged
merged 4 commits into from
Aug 18, 2024

Conversation

Cruikshanks
Copy link
Member

@Cruikshanks Cruikshanks commented Aug 16, 2024

https://eaflood.atlassian.net/browse/WATER-4563
https://eaflood.atlassian.net/browse/WATER-4564
https://eaflood.atlassian.net/browse/WATER-4565

Part of the work to display a licence's history to users (mod log)

It's a trap!

We have made the same mistake as the previous team. When we believed that a version (charge, licence, or return) had a one-to-one relationship with NALD mod log records, a JSONB field in each was a suitable solution to capturing just the information we needed. After all, it's only the historical records we have to worry about.

But when we learned that a version record could be linked to multiple mod logs, we should have taken a different approach. Instead, we ploughed on with our JSON column altering its name and default to match. 🤦😬

Once you've started down the JSONB road, it is easy to get trapped!

Thankfully, we've come to our senses before this saw the light of day in production. The mod log data we are importing needs to go into its own table, and we will link our version records accordingly. A 'standard' relationship database solution.

So, in this change, we replace the import we did just for return mod logs into the return versions table with one that can handle importing all mod logs for all version types.

The change Replace mod_logs columns with a table has created the table we can now populate using queries we'll add in this change.

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

> Part of the work to display a licence's history to users (mod log)

In [Include mod log info in return versions import](#990) we extended the existing return versions import (part of 'charging-import') to extract the matching return log for a return version and populate its new `mod_log` field.

However, we've since learned that a version in NALD can have multiple mod log records. Each my have different information and our users want to see this in WRLS.

This change amends what we did to extract _all_ mod logs linked to a return version and store them in its now named `mod_logs` field.
@Cruikshanks Cruikshanks added the enhancement New feature or request label Aug 16, 2024
@Cruikshanks Cruikshanks self-assigned this Aug 16, 2024
@Cruikshanks Cruikshanks changed the title Update rtn version mod log import to match all Replace rtn vers mod log import with all versions Aug 18, 2024
This never went live into production.
It felt prudent to keep them distinct from the other queries and follow the existing pattern.
@Cruikshanks Cruikshanks marked this pull request as ready for review August 18, 2024 10:32
@Cruikshanks Cruikshanks merged commit 75398ff into main Aug 18, 2024
4 checks passed
@Cruikshanks Cruikshanks deleted the alter-return-version-mod-log-import branch August 18, 2024 10:33
Cruikshanks added a commit that referenced this pull request Aug 19, 2024
https://eaflood.atlassian.net/browse/WATER-4636

> Part of the work to display a licence's history to users (mod log)

Now that we are [importing the NALD mod logs](#998) and linking them to their WRLS version records (charge, licence and returns) we can look to update the WRLS records with their missing reasons.

We've done some work with the Billing & Data team to map NALD reasons to those in WRLS. There are a couple that don't map, and for those [water-abstraction-system](https://github.com/DEFRA/water-abstraction-system) will fall back to whatever reason description we have in the mod log. For the rest though, we can fill in their missing `reason` field with the mapped WRLS reason. We can then start displaying this to users in the out new UI screens.

This change adds another query to the charging data import, that will do the mapping for those WRLS return versions that

- have an empty `reason``
- have mod log records
- the first mod log record has a reason code
- the reason code is mapped to WRLS
Cruikshanks added a commit that referenced this pull request Aug 20, 2024
https://eaflood.atlassian.net/browse/WATER-4636

> Part of the work to display a licence's history to users (mod log)

Now that we are [importing the NALD mod logs](#998) and linking them to their WRLS version records (charge, licence and returns) we can look to update the WRLS records with their missing reasons.

We've worked with the Billing & Data team to map NALD reasons to those in WRLS. There are a couple that don't map, and for those, [water-abstraction-system](https://github.com/DEFRA/water-abstraction-system) will fall back to whatever reason description we have in the mod log. For the rest, though, we can fill in their missing `reason` field with the mapped WRLS reason. We can then start displaying this to users on our new UI screens.

This change adds another query to the charging data import that will do the mapping for those WRLS return versions.

- that have an empty `reason`
- that have mod log records
- the first mod log record has a reason code
- the reason code is mapped to WRLS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant