Substantially improve product searches by showing top 30 items only#937
Substantially improve product searches by showing top 30 items only#937patzly merged 1 commit intopatzly:masterfrom
Conversation
|
Thank you so much for your contribution! Finally, someone who understands our (admittedly messy) code and apologies for the quality. When we first started, I was teaching my twin brother Dominic Android development with Java through this “tiny project” he wanted to build with me. I had taught myself Java and Android about a year before that. Now, years later, he has finished his computer science degree, I’m almost finished with mine, and he no longer works with Android. That leaves me maintaining this huge project with limited time and many other simpler projects. A complete rewrite in Kotlin and Compose would take far more time than I can currently afford, so I highly appreciate pull requests like yours. |
|
Congratulations to Dominic on finishing his computer science degree! It’s funny how small projects can sometimes grow into really big ones. :) You’ve created a truly great and useful piece of software—we’ve been using it at home for years, and since then not a single food product has expired. :) At this point, we already have 1,787 products in the database. :D We’re now running Grocy on a dedicated Android-based barcode scanner. Since it’s not as fast as a flagship smartphone, some performance improvements were (and still are) necessary. After my recent commits, the app has become usable, though still a bit laggy. I think replacing FuzzyWuzzy with native database full-text search would be a better approach. I already have a local test version with full-text search working - I just need to figure out how to integrate “pending” products into the results before it’s ready as a PR. I am still not sure what those pending products are? Products created locally, sent to the server but not yet part of the main products list? I will eventually figure that out. :P The refactoring into fulltext has made the app much more comfortable to use, so hopefully I’ll be able to finalize it soon! |
After growing inventory for many years, product searches started to be really slow!
That was especially noticeable on older HW where it would take ~3 seconds to display the list of products (in the ProductChooser initially as well as during filtering by adding characters to the search query).
This change restricts all fuzz searches to top 30 items which should be more than enough.
Additionally it also restricts the initial list of products in ProductChooser to 30 - it is unlikely that anyone would scroll manually through ~2000 products to pick one after scanning a new bar code. We could not display a list at all and wait for at least a single character in the Product name field but showing first 30 is probably a bit nicer. While mostly useless, it still at least shows the user that search results will be displayed there.
This change does not affect initial list of Master data. I think it is expected to see all products there even without a search. Of course some kind of live pagination would be helpful but I think it is probably used very rarely anyway and waiting there is not a major problem.