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 'currentVersion' modifier to LicenceModel #1133

Merged
merged 13 commits into from
Jun 24, 2024

Conversation

Cruikshanks
Copy link
Member

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 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 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!

This change does both then updates anything currently handling a current licence version to use them.

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 Cruikshanks added the housekeeping Refactoring, tidying up or other work which supports the project label Jun 21, 2024
@Cruikshanks Cruikshanks self-assigned this Jun 21, 2024
@Cruikshanks Cruikshanks marked this pull request as ready for review June 24, 2024 09:11
@Cruikshanks Cruikshanks merged commit 56a50d6 into main Jun 24, 2024
6 checks passed
@Cruikshanks Cruikshanks deleted the add-current-version-to-licence-model branch June 24, 2024 09:11
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