-
Notifications
You must be signed in to change notification settings - Fork 0
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
Create return cycle #1353
Merged
Merged
Create return cycle #1353
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Cruikshanks
requested changes
Sep 26, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have some suggested changes from a first pass. Give me a ping if you have any questions/challeneges.
db/migrations/public/20240918125758_create-return-cycles-view.js
Outdated
Show resolved
Hide resolved
Cruikshanks
requested changes
Oct 1, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some minor suggested changes
test/services/jobs/return-logs/fetch-return-cycle.service.test.js
Outdated
Show resolved
Hide resolved
…ion-system into create-return-cycle
…ion-system into create-return-cycle
Cruikshanks
approved these changes
Oct 1, 2024
Cruikshanks
added a commit
that referenced
this pull request
Oct 10, 2024
When attempting to run the acceptance tests we found most of them were now failing. After investigating we tracked it down to a [recent change made](#1353) to the `ReturnLogHelper`. We started setting `returnCycleId` to a generated UUID. Normally, return logs have this set to the return cycle they fall within. However, if it is set (in the DB proper) the ID _must_ exist in `return.return_cycles`. We've opted not to replicate foreign key constraints in our test DB legacy migrations because of the additional complexity they would add to our unit tests, for something we don't need to cover in them. It wasn't being set before, because our premise for the helpers is they set _only_ what is required in order to insert a record. Any fields that are 'optional', are expected to be set within the test using the helper and passed in. Fortunately, removing the call in the helper hasn't broken any existing tests, further highlighting we don't really need this defaulted for what we are testing. And removing the call gets the acceptance tests passing again!
Cruikshanks
added a commit
that referenced
this pull request
Oct 10, 2024
https://eaflood.atlassian.net/browse/WATER-4543 In [Create return cycle](#1353) we added a new seeder for return cycles. They are part reference, part transactional records. When starting with a clean environment you would need to seed existing return cycles. Going forward, they are automatically created as part of creating returns logs. When we come to creating the first return log for a cycle, if the cycle record does not exist then we create it. When we added the seeder though, the query we wrote was purely an insert. It should have been an `upsert` because seeders need to be written in such a way they can be run multiple times against the same environment (both test and 'real'). This fixes the query used to actually be an upsert.
Cruikshanks
added a commit
that referenced
this pull request
Oct 10, 2024
When attempting to run the acceptance tests we found most of them were now failing. After investigating we tracked it down to a [recent change made](#1353) to the `ReturnLogHelper`. We started setting `returnCycleId` to a generated UUID. Normally, return logs have this set to the return cycle they fall within. However, if it is set (in the DB proper) the ID _must_ exist in `return.return_cycles`. We've opted not to replicate foreign key constraints in our test DB legacy migrations because of the additional complexity they would add to our unit tests, for something we don't need to cover in them. It wasn't being set before, because our premise for the helpers is they set _only_ what is required in order to insert a record. Any fields that are 'optional', are expected to be set within the test using the helper and passed in. Fortunately, removing the call in the helper hasn't broken any existing tests, further highlighting we don't really need this defaulted for what we are testing. And removing the call gets the acceptance tests passing again!
Cruikshanks
added a commit
that referenced
this pull request
Oct 10, 2024
https://eaflood.atlassian.net/browse/WATER-4543 In [Create return cycle](#1353) we added a new seeder for return cycles. They are part reference and part transactional records. When starting with a clean environment, you would need to seed existing return cycles. Going forward, they are automatically created as part of creating return logs. When we create the first return log for a cycle, if the cycle record does not exist, we make it. When we added the seeder, though, the query we wrote was purely an insert. It should have been an `upsert` because seeders need to be written so they can be run multiple times against the same environment (both test and 'real'). This fixes the query used to actually be an upsert.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
https://eaflood.atlassian.net/browse/WATER-4543
As part of the work to replace the legacy system NALD we need to generate return logs. This PR creates a return cycle if one does not already exist and adds it to the return log