-
-
Notifications
You must be signed in to change notification settings - Fork 449
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
[Up for Adoption] Allow to scan barcodes offline #2069
Comments
We can download the file on the first run and then store it in the DB. I will try that. |
…ile and stored in the database.
@teolemon please review... as of now, since the data is too big (~700000 products), so it's taking too much time to store in the database. |
@jinqian @huzaifaiftikhar @PrajwalM2212 any ideas to massively increase it client side ? |
No, I didn't. I did for a subset of 10,000 products and it took around 5-6 minutes. |
Do you have an idea of the size of the DB for 10k products ? |
Your code is trying to download it during the first run. That is great but I am more worried about the time that will take.
|
@teolemon No, I didn't check that. |
What if we don't save the data in a database. When a user scans a product, we will |
@prashantkh19 That is why I was saying that we download like 10000 products at every attempt rather than as whole |
@PrajwalM2212 yeah, it can be good, we can divide the csv file based on sorted barcodes, each file having let say, 10000 products and a separate file which contains the metadata of all the csv files. That way, we will need to scan just 2 files for each product scan, and it will take hardly 5 seconds to get the results. And maybe we can try hashing each csv also. |
weird: http://greenrobot.org/wordpress/wp-content/uploads/2016-07-08-android-orm-performance-benchmark.png |
…base operations.
Optimized Version: took around 4 minutes to |
It can still be optimized more, as I am saving a list of max 15000 entities each time as of now. If I increase the list size, then time can be reduced but increasing the size of the list may result in crashes due to memory. A better Data Structure (space optimized) than ArrayList may help or if we somehow can store |
@teolemon @PrajwalM2212 can you review the latest commit? |
…ile and stored in the database.
…base operations.
…ile and stored in the database.
…base operations.
…ile and stored in the database.
…base operations.
@teolemon what about optionally limiting the loading/excerpt to a specific store? Through the preferences maybe. I know I do most of my grocery shopping in one store so... |
@serpico That will be V2 or 3. For now, we can afford to load everything. In the future, we'll try to let people control how much detail they want (like full products) and what countries, what stores they want. Besides, right now, we don't know if a product is sold everywhere. |
…ile and stored in the database.
…base operations.
…ile and stored in the database.
…base operations.
@teolemon Can you break this down in small tasks ? |
Hi! @teolemon Do you consider an approach with downloading the whole sqlite DB file? From top of my head I see offline flow V1 next:
|
I'd suggest we keep a |
Also, we keep the size problem. I think the best approach would just to store a country into the local db with just a few attributes: name, ecoscore, nutriscore, brand and quantity maybe |
@VaiTon @teolemon I would like to implement this. These are the subtasks :
For this we will need to store the nutriscore, nova group (or CO2) , eco score and ingredient analysis. |
Also , can you please explain the CSV design. @teolemon |
@kartikaysharma01 It's basically a very minified version of the database. |
And I believe the current export is broken, here's the Python script that converts the daily CSV export: https://github.com/openfoodfacts/openfoodfacts-server/blob/main/scripts/generate_dump_for_offline_apps_off.py |
What
Why
Datasource
I've created a special excerpt of the database, which has the required data to scan products for France. This is 11 Mb zipped, and 37Mb unzipped.
http://fr.openfoodfacts.org/data/offline/fr.openfoodfacts.org.products.small.csv.tgz
https://world.openfoodfacts.org/data/offline/en.openfoodfacts.org.products.small.csv.zip
Can we download this data and store it in the DB ?
I can create it for other countries on demand, but right now it's a test.
And I believe the current export is broken, here's the Python script that converts the daily CSV export: https://github.com/openfoodfacts/openfoodfacts-server/blob/main/scripts/generate_dump_for_offline_apps_off.py
I have fixed the CSV export for NOVA which wasn't exported correctly:
https://world.openfoodfacts.org/data/offline/en.openfoodfacts.org.products.small.csv.zip
Equivalent code on iOS
Data structure
It's basically a very minified version of the database.
code product_name quantity brands nutriscore_grade nova_group ecoscore_grade
8938506580127 Dien Bao sweet potato vermiceilli
8938506854082 Virgin Coconut Oil 1 l Vietcoco
8938506854471 Lait De Coco Sterilisé 4.0
8938506854518 Thanh vinh Organic
8938506854563 coconut cream 13.5 fl.oz vietcoco 4.0
Proposed visual assets
https://storage.googleapis.com/icons.google.com.a.appspot.com/google-assets/system_icons/quantum/file/res-export/ic_cloud_off_24px.svg
Part of
Screenshots from the existing PR and the iOS app and other apps based on OFF
Random
https://world.openfoodfacts.org/data/output-small.csv
Database at 1GO, new export: 87MB
https://github.com/wmentzel/dump-creator
The text was updated successfully, but these errors were encountered: