-
-
Couldn't load subscription status.
- Fork 758
Update sum calculation in order_cycle_customer_totals spec #13571
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
base: master
Are you sure you want to change the base?
Update sum calculation in order_cycle_customer_totals spec #13571
Conversation
|
I unassigned the PR by mistake, but I cannot take it back, I don't have the permission. |
|
I am having a concern with my changes actually. I think it would be more efficient for memory to use So I will use |
|
Actually, it is a bit more tricky than this, |
4489df0 to
78a7db8
Compare
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 started refactoring the sum calculation for the whole reporting part. It makes the scope wider than the initial issue, but I thought it was the occasion to do it. Please tell me if I should reduce it.
By the way, I am still having 5 Rubocop warnings regarding Cyclomatic Complexity, these issues were already present, the only solution I am seeing is to introduce other methods to split values list generation, but I am not sure it will improve code readability. Please tell me if you think I should still address these issues in this PR.
| end | ||
|
|
||
| def tax(query_result_row) | ||
| line_items(query_result_row)&.map do |line_item| |
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.
The safe operator is used here, but maybe to replace it with .to_a will make the code more readable and the result more accurate (0 instead of nil).
|
I am assuming that the PR will be squashed before the merge, but please tell me if you have an other approach to keep the git tree clean. |
I updated the rubocop TODO file so the build should green now. |
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 am assuming that the PR will be squashed before the merge, but please tell me if you have an other approach to keep the git tree clean.
We don't squash PR on merge, we prefer to keep the git history. Usually it's better to clean up your git history before submitting a PR, see https://github.com/openfoodfoundation/openfoodnetwork/wiki/Making-a-great-pull-request#keep-your-commit-history-clean-tidy-and-up-to-date
But note, don't change your git history once the PR has been reviewed, otherwise it gets too confusing.
Thanks for you help, the PR looks good. 👍
| quantity: proc { |line_items| line_items.to_a.sum(&:quantity) }, | ||
| item_price: proc { |line_items| line_items.sum(&:amount) }, | ||
| item_fees_price: proc { |line_items| line_items.sum(&:amount_with_adjustments) }, | ||
| quantity: proc { |line_items| line_items.to_a.map(&:quantity).sum(&:to_) }, |
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.
Typo ? Will be fixed in the next commit.
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.
Looking good!
|
I think that it's still a good idea to do a sanity check on reports in staging. |
|
I have checked various reports on FR staging and I got the reports:
Now about values, I checked especially the [Revenues By Hub](report https://staging.coopcircuits.fr/admin/reports/revenues_by_hub), from 01/05/25 to 30/06/25:
- Master branch
The results are identical, so it seems that these changes are not affecting the reports, as we expected.
Actually, it is more a coherence test than a sanity test, but I think it is fine with our needs.
Fyi, to do the test quickly, I have just switched quickly the branches on FR staging instance, and restarted Puma each time. |
|
Let's try on Payment Totals report, as where were more changes here. I used the same period.
- Master branch
No changes, so it looks good too.
I can just see a rounding issue on the shipping cost for both cases, but it is an other issue I guess.
|
|
@pacodelaluna there is a conflict with master, could you rebase your branch ? |
c0db004 to
e298c7e
Compare
3f4fb6c to
105b62c
Compare
|
@rioug I am sorry but I have also lost your fixes about Rubocop warnings when I pushed with force last week... I could add back the Rubocop exclusions, but I couldn't regenerate the rubocop TODO file, I am getting an error locally: I will try to fix this up asap. |
|
I've seen that error, too. Try running |
105b62c to
0a0014b
Compare
0a0014b to
6e1afa5
Compare
|
Ok, actually I succeeded in by upgrading the Rubocop version to 1.81.6, but it was adding extra warnings. Then, I run it adding |
|
Nice job 💯 I got curious and run the command on top of current master branch, and I was able to reproduce the rubocop issue. I also found that upgrading RuboCop fixes the problem. You've workaround that successfully, so not a blocker for this PR, but I'll create a separate PR to master so that the problem does not bite other devs in the future. |
|
@deivid-rodriguez Great! Actually I was wondering if we should add the extra config or update Rubocop gem. But you manage it, thanks 🙏 |




What? Why?
Initial objective was to fix a warning, but it was not possible to reproduce the issue.
Then, we decide to update the sum calculation to be consistent with previous changes.
What should we test?
It is a refactoring, unit tests are already provided for this change.
Release notes
Changelog Category (reviewers may add a label for the release notes):