[16.0][IMP] shopfloor: improve performance of generic_find#1174
[16.0][IMP] shopfloor: improve performance of generic_find#1174nicolas-delbovier-acsone wants to merge 3 commits into
generic_find#1174Conversation
When the parser was able to detect some type (e.g. "lot") this is stupid to test all the others that we know will not work ("packaging", "product", ...)
In `generic_find`, the list of parsed results always starts with an "unknown" type representing the raw barcode string. Processing this first causes unnecessary database queries across all handlers before checking explicitly parsed types (e.g. GS1). Sort `parse_results` to push "unknown" types to the end of the loop, ensuring that high-confidence, parsed barcode matches are evaluated first.
jbaudoux
left a comment
There was a problem hiding this comment.
Definitely better but not enough.
I think I explained it in the issue. You need to loop over each result and their type to refine the result.
First result is ean, search for products. Next result is lot, search for lots of found products. Etc...
| @@ -1 +1 @@ | |||
| from . import search | |||
| from . import barcode_parser | |||
There was a problem hiding this comment.
I am not against reverting this change if really you prefer so.
I was just applying the "boy scout rule" to bring this file name in line with naming conventions while I was working in the area.
I do not understand how what you say could work? In Are you suggesting that we should not return on first result found and always test all possible types first and then decide which record I want to link to the returned |
Yes you need to process all the results and parse according their type. The one to return is the last that made a match. If you match a lot, you return the lot. If you match only a product, you return a product. |
Problem
The
generic_findmethod inshopfloorsuffered from two performance bottlenecks during barcode scanning:'lot'), the loop structure would blindly execute database queries across all other active handlers (e.g.,'package','product','location')."unknown"result type (representing the raw string fallback) at the beginning of the results collection, the method consistently evaluated this generic fallback first (and thus tested all possible types instead of only one).Also includes
shopfloor_gs1-> renamed to not be misleading in the future / improve code navigation