Fix cached data in ProcessBillingBatchService #166
Merged
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-3906
As part of implementing Handle errors in ProcessBillingBatchService we refactored the
ProcessBillingBatchService
to make the code cleaner and easier to read.One of the changes was moving the
generatedInvoices
andgeneratedInvoiceLicences
to the module scope rather than just in the method scope. It saved us from having to pass them around the place which removed a bunch of 'cruft'. What we didn't take into account is they would be cached between calls to the service.Now it's at module scope the data from previous runs is being cached and still exists when a new one starts. So, we're getting to the finalise stage and we're trying to persist old data from a previous run!
This change resolves the issue.
For reference, we move the variables into the scope of the
go()
function removing the issue of the data being cached at the global scope.We then take a halfway house approach; we pass the information into our methods but we accept having to mutate the data rather than pass back a modified copy.
Screenshot of logs showing caching