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

Move UUID generator to single place #415

Merged
merged 5 commits into from
Sep 11, 2023

Conversation

Cruikshanks
Copy link
Member

DEFRA/water-abstraction-team#96

There are a number of places in water-abstraction-system where we need to generate a UUID. This is what the records in the DB use for their primary keys. We generate them in tests, for performance reasons (reduce hits on the DB) or simply because the previous team forgot to set the table to automatically generate them!

You have to require() the module and then it's a one-liner to generate the method. So, moving it to our own thing didn't seem necessary.

But there is some config you need to apply, and we have duplicated that in a number of places. Who knows where a new dev will encounter randomUUID({ disableEntropyCache: true }) for the first time! 😆

Admittedly, it's borderline whether there is value in doing this. But we've come to the conclusion we should

DEFRA/water-abstraction-team#96

There are a number of places in [water-abstraction-system](https://github.com/DEFRA/water-abstraction-system) where we need to generate a [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier). This is what the records in the DB use for their primary keys. We generate them in tests, for performance reasons (reduce hits on the DB) or simply because the previous team forgot to set the table to automatically generate them!

You have to `require()` the module and then it's a one-liner to generate the method. So, moving it to our own thing didn't seem necessary.

But there is some config you need to apply, and we have duplicated that in a number of places. Who knows where a new dev will encounter `randomUUID({ disableEntropyCache: true })` for the first time! 😆

Admittedly, it's borderline whether there is value in doing this. But we've come to the conclusion we should.
@Cruikshanks Cruikshanks added the housekeeping Refactoring, tidying up or other work which supports the project label Sep 8, 2023
@Cruikshanks Cruikshanks self-assigned this Sep 8, 2023
@Cruikshanks Cruikshanks marked this pull request as ready for review September 8, 2023 15:03
Copy link
Contributor

@Jozzey Jozzey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Cruikshanks Cruikshanks merged commit dd2db2a into main Sep 11, 2023
@Cruikshanks Cruikshanks deleted the move-uuid-generator-to-single-place branch September 11, 2023 11:48
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.

2 participants