-
-
Notifications
You must be signed in to change notification settings - Fork 505
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
Bank Org Request Export - Include Custom Units #4608
Conversation
Use fixes specific values instead of calculated ones in most places
Hrm. I did an export that looked clean, but then I added a request that just had pads with 233 units. I got a "no implicit conversion from nil to integer" on line 99 of export_request_service. (Note: I made partner group 1 have all the categories, and gave pads a category of Period Supplies first). |
@cielf Fixed! The issue was similar to the one in another PR, where "some item -" was being used instead of "some item" when the default-unit was selected. |
|
||
# It's possible that the unit is no longer valid, so we'd | ||
# add that individually | ||
if item_request.request_unit.present? && !item.request_units.pluck(:name).include?(item_request.request_unit) |
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.
Can we grab all the request_units at the top rather than doing a separate DB query per item here?
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 followed another alternative of switching to a set and adding rather than re-testing; avoids the extra DB call.
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'm confused - this avoids an extra DB call per item, but you're still doing a DB call per item. I think you might be missing an includes
somewhere? Or am I reading this wrong?
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.
@dorner ok -- I followed some log/bullet.log advice and also watched the logs as I loaded this page. From that I sprinkled a few .includes
around to pre load things. What do you think?
Also pluralize consistently
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.
One last question.
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 ran an export that seemed to work, then added a request for 1 box of pads. Then I exported again, and got a Type Error no implicit conversion from nil to integer. It failed at export_request_service.rb line 99, and it does look like it failed on the newly added item. I think headers_with_indexes might be to blame -- that there was a new item/unit combo, but headers_with_indexes was already defined, hence the boxes column header not defined, hence boom.
@cielf Fixed the issue you ran into -- it was a case of qty |
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.
Looks good
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.
Good on my end too!
* Modify exporter to use real item_requests * Include the units of the requested items * Rename to more correct item_requests * Reorganize and stupify spec Use fixes specific values instead of calculated ones in most places * Use dash to separate unit * Re-arrange factory create a bit * Create item_requests for realistic mock data * Only add new export units when custom-units feature is enabled * Handle the case where the item custom-unit was deleted later * Fix request export for default-unit * Use empty string for request unit in spec * Extract common name_with_unit for request items * Use set in item header calc to simplify duplicates Also pluralize consistently * Remove old commented out code * Specify exact expected values * Deal with pluralization conflict and update spec [rubyforgood#4405] * Prefetch some data and clarify all_item_requests name [rubyforgood#4405] * Change spec to send AR relation
@awwaiid: Your PR |
Implements #4405, adding custom units to request export.