Skip to content
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

Show by default unranked search results (for 25 first results of the query, with more loading on scroll) #1333

Closed
Tracked by #1326
monsieurtanuki opened this issue Mar 25, 2022 · 5 comments · Fixed by #1437
Assignees
Milestone

Comments

@monsieurtanuki
Copy link
Contributor

From #1326 (I could not create an issue directly from it)

Show by default unranked search results (for 25 first results of the query, with more loading on scroll, with just : https://fr.openfoodfacts.org/cgi/search.pl?search_terms=salmon&action=process&fields=brands,product_name,image_small_url,image_front_thumb_url,quantity,nutrition_grades_tags,ecoscore_tags&json=1&page_size=25

What we do on Android is infinite scroll by loading in batches of 25 or 50. So if the user starts scrolling, we load additional batches of 25.
We can choose to store (or not) those search results for later loading (they are lightweight, and fast to get again, so either option is ok)

Part of

@monsieurtanuki monsieurtanuki changed the title Show by default unranked search results (for 25 first results of the query, with more loading on scroll Show by default unranked search results (for 25 first results of the query, with more loading on scroll) Mar 25, 2022
@monsieurtanuki monsieurtanuki self-assigned this Mar 25, 2022
@monsieurtanuki
Copy link
Contributor Author

Currently

  1. the user enters keywords
  2. we try to find if a similar keyword search is already in the local database
  • primary key: "search/$keywords"
  • data: timestamp and barcode list
  1. if found, we display the product list from the database, and the timestamp to say "data is that old", with a snackbar to refresh the data from the back-end
  2. if not found, we call the back-end, and populate the database with the results

Probable changes

  1. (database) the primary key should contain the page number and the page size, e.g. "search/$keywords,1,25"
  2. (database) the data should also contain the size of the full list (we get that from the back-end), in order to be able to be able to say to the user something like "there are still 96780 products to download, is it worth?" or "no need to scroll down again, we've downloaded everything"
  3. (product list display) we should now display not one product list, but a list of product lists (each page being a product list in the database)
  4. (UI/UX) In first approach I won't use the scroll gesture to trigger the next 25 products download, but display a verbose button at the bottom of the list instead. The scroll gesture callback can be added afterwards.

@monsieurtanuki
Copy link
Contributor Author

@teolemon @M123-dev Something like this?
Simulator Screen Shot - iPhone 8 Plus - 2022-03-28 at 15 50 32

@teolemon
Copy link
Member

I would only make it manual in a potential power-saving mode, otherwise I would autoload like we did in V1.

@monsieurtanuki
Copy link
Contributor Author

I understand.
Still, I'll code it "my" way in a first phase, for debug reasons, and because an autoload would prevent users from knowing how many "lasagne" they'll have to download (e.g. 1083 in France vs. 53 in the USA).
Then another developer can code the autoload on top of my code.
The principles are the same anyway: downloading data by batches of 25 while displaying the whole list, the only difference being what triggers the next download.

@monsieurtanuki
Copy link
Contributor Author

I should be able to PR on Thursday.

monsieurtanuki added a commit to monsieurtanuki/smooth-app that referenced this issue Apr 1, 2022
New files:
* `paged_product_query.dart`: Paged product query (with pageSize and pageNumber).
* `partial_product_list.dart`: List of Products out of partial results (e.g. paged results).

Impacted files:
* `category_product_query.dart`: now extending new class `PagedProductQuery`.
* `dao_product_list.dart`: now storing "total size" of paged results; now including page size and page number in the primary key; now returning a bool for method `delete`.
* `database_product_list_supplier.dart`: now loads paged results page after page.
* `keywords_product_query.dart`: now extending new class `PagedProductQuery`.
* `new_product_page.dart`: unrelated fix about back icon on Android/iOS.
* `onboarding_flow_navigator.dart`: unrelated fix about back icon on Android/iOS.
* `personalized_ranking_page.dart`: refactoring.
* `product_list.dart`: removed now unused product list type (pnns); added fields page size, page number and total size for paged results; refactored.
* `product_list_page.dart`: refactored.
* `product_list_supplier.dart`: now using `PagedProductQuery` and `PartialProductList`.
* `product_query_model.dart`: added a `clear` method to go back to top page; added method `loadNextPage` and `loadFromTop`.
* `product_query_page.dart`: now displaying pages results with a "load next" button; unrelated fix about back icon on Android/iOS.
* `product_query_page_helper.dart`: refactored.
* `query_product_list_supplier.dart`: now using `PagedProductQuery`.
* `scan_page_helper.dart`: refactored.
* `search_page.dart`: refactored.
* `summary_card.dart`: refactored.
monsieurtanuki added a commit to monsieurtanuki/smooth-app that referenced this issue Apr 1, 2022
monsieurtanuki added a commit to monsieurtanuki/smooth-app that referenced this issue Apr 1, 2022
Impacted file:
* `product_query_page.dart`
monsieurtanuki added a commit to monsieurtanuki/smooth-app that referenced this issue Apr 1, 2022
@teolemon teolemon linked a pull request Apr 2, 2022 that will close this issue
@teolemon teolemon added this to the V1 milestone Apr 2, 2022
monsieurtanuki added a commit to monsieurtanuki/smooth-app that referenced this issue Apr 5, 2022
monsieurtanuki added a commit to monsieurtanuki/smooth-app that referenced this issue Apr 5, 2022
Impacted file:
* `product_query_page.dart`
monsieurtanuki added a commit to monsieurtanuki/smooth-app that referenced this issue Apr 6, 2022
monsieurtanuki added a commit to monsieurtanuki/smooth-app that referenced this issue Apr 6, 2022
Impacted files:
* `dao_product_list.dart`: added explicit constant
* `database_product_list_supplier.dart`: added comments
* `Podfile.lock`: wtf
* `product_query_model.dart`: now returning relevant `bool` for async loads
* `product_query_page.dart`: minor refactoring
Repository owner moved this from Pull Requests to Done in 🤳🥫 The Open Food Facts mobile app (Android & iOS) Apr 6, 2022
monsieurtanuki added a commit that referenced this issue Apr 6, 2022
New files:
* `paged_product_query.dart`: Paged product query (with pageSize and pageNumber).
* `partial_product_list.dart`: List of Products out of partial results (e.g. paged results).

Impacted files:
* `category_product_query.dart`: now extending new class `PagedProductQuery`.
* `dao_product_list.dart`: now storing "total size" of paged results; now including page size and page number in the primary key; now returning a bool for method `delete`.
* `database_product_list_supplier.dart`: now loads paged results page after page.
* `keywords_product_query.dart`: now extending new class `PagedProductQuery`.
* `new_product_page.dart`: unrelated fix about back icon on Android/iOS.
* `onboarding_flow_navigator.dart`: unrelated fix about back icon on Android/iOS.
* `personalized_ranking_page.dart`: refactoring.
* `Podfile.lock`: wtf
* `product_list.dart`: removed now unused product list type (pnns); added fields page size, page number and total size for paged results; refactored.
* `product_list_page.dart`: refactored.
* `product_list_supplier.dart`: now using `PagedProductQuery` and `PartialProductList`.
* `product_query_model.dart`: added a `clear` method to go back to top page; added method `loadNextPage` and `loadFromTop`.
* `product_query_page.dart`: now displaying pages results with a "load next" button; unrelated fix about back icon on Android/iOS.
* `product_query_page_helper.dart`: refactored.
* `query_product_list_supplier.dart`: now using `PagedProductQuery`.
* `scan_page_helper.dart`: refactored.
* `search_page.dart`: refactored.
* `summary_card.dart`: refactored.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

2 participants