-
-
Notifications
You must be signed in to change notification settings - Fork 730
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
Allow user to show/hide totals with a checkbox toggle #6850
Comments
Hi @lin-d-hop Does "Display Total Rows" refer to "Summary Rows"? In the report code, I see that if the selected format is CSV or JSON, the summary rows flag will be unchecked. openfoodnetwork/lib/reporting/report_renderer.rb Lines 24 to 28 in ee70645
openfoodnetwork/lib/reporting/report_renderer.rb Lines 13 to 15 in ee70645
I noticed the same thing in the UI Do you want to change that behavior? |
Hi @abdellani Out of interest, do you think it would be difficult to change this behaviour so that you can choose to show summary rows on CSV and JSON formats? This fell out of scope in the last reports changes and we had the impression it was a tricky to include the totals rows, particularly for the JSON. Don't spend more than an hour thinking about this question :) |
To answer your question, I updated the report to authorize summary rows on CSV. Sales Tax Totals By OrderOrder Cycle Supplier Totals |
Cool, any idea about the JSON? Given there's still 30mins left in that hour ;) |
This is the result: https://gist.github.com/abdellani/4ae748bd891ae99e81fa2f509c65e8cc I think we have a small problem, the name of the attributes in the summary sub-document. {
"producer": "",
"product": "",
"variant": "TOTAL",
"quantity": 6,
"total_units": "6.0",
"curr_cost_per_unit": "",
"total_cost": "420.0"
} I notice another problem. I remove {
"error": "Please supply Ransack search params in the request"
} If I replace it with |
Thanks @abdellani! From a dev perspective, how hard would it be for us to create a search param like 'include totals' which if true returns a new sub document appended to the end with different attributes? This needs some thought and design, but in theory would this be difficult? Though our hour is up :) It's a known thing that you need to supply some search params for the API RQ, and I think a good buffer to try stop an inexperienced API dev from crashing our servers with a request for too much data :) |
We already have that search param: One possible way to do it is by updating the openfoodnetwork/lib/reporting/report_rows_builder.rb Lines 47 to 65 in ee70645
|
Hi @abdellani , sorry I didn't realise you had already started on this. It sounds like we don't have any reason for So @lin-d-hop after my PR, should we proceed with allowing summary rows and headers on all formats? |
Just FYI, the use case to keep .csv without formatting was to easily allow csv to be imported elsewhere. Summary and total rows makes .csv less readable as these rows are not properly defined (you can't link a header row to an order for example, unless you are a human and you see the two are linked). If we are making changes towards having both .csv and .xlsx version 100% alike I would suggest we drop maintaining .csv. It's easy to save in .csv from a .xslx version. What do you think? |
This is just my opinion, but I think:
Unless there's high risk of mistakes, I don't think we should place arbitrary limits on what people can do. I also think header rows should be treated in the same way. I notice that we currently have an inconsistency: you can choose them for CSV but they never appear. It should be deselected by default but allowed if selected. |
Yes it's covered by #9546
Perhaps on the tech side, but we shouldn't forget testing. @filipefurtad0 what do you think? |
Good points. It seems to me that CSV is easy to test/maintain - we do it already in our suite (like for the product import feature). I would not know how to test XLSX files for content and we have issues testing PDFs as well, so I'd say these are more challenging to maintain. |
FYI product import allows xslx 👍 |
Yes, but I don't think we test it 🙈 |
I do agree that if it isn't onerous to include the summary option in the CSV version we should do it. it will remove confusion. Given that we now allow this on API version, CSV is the only one left. The original issue here is soooo outdated.... from before the new reports framework. I can create a new issue for this actual task and close this one. |
Description
To increase the utility of this report we wish to enable the user to show and hide the Totals rows (as displayed in the CSV mock)
The user will have an additional checkbox filter:
When the box is checked, total row will be included.
When the box is not check the CSV download and the UI report will not have totals rows
This needs to be applied to both the By Producer and By Order pivots of this report.
Issue #6846 will be very similar to this.
Acceptance Criteria & Tests
The text was updated successfully, but these errors were encountered: