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 generation to single place #96

Closed
Cruikshanks opened this issue Sep 8, 2023 · 1 comment
Closed

Move UUID generation to single place #96

Cruikshanks opened this issue Sep 8, 2023 · 1 comment
Assignees
Labels
housekeeping Refactoring, tidying up or other work which supports the project

Comments

@Cruikshanks
Copy link
Member

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.

@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 added a commit to DEFRA/water-abstraction-system that referenced this issue Sep 8, 2023
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 added a commit to DEFRA/water-abstraction-system that referenced this issue Sep 11, 2023
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
Copy link
Member Author

This is done!

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

No branches or pull requests

1 participant