davidhealey / waistline

Libre calorie counter app for Android. Built with Cordova.
567 stars 67 forks source link

Food search functionality is broken (?) #779

Open savchenko opened 10 months ago

savchenko commented 10 months ago

Going to "Foods", typing "avocado" and pressing enter results in an endless spinner presented to a user.

No meaningful error (403, timeout, etc) is shown. Unclear how to debug further.

davidhealey commented 10 months ago

Is it only avocado or other terms too?

savchenko commented 10 months ago

Is it only avocado or other terms too?

The plot thickens. I have tried "cola" — it works via 4G and WiFi while "avocado" doesn't work using either one.

Further, looking at DNS requests log, I see only the following hosts blocked:

app-measurement.com
*.doubleclick.net
collector.github.com
improving.duckduckgo.com

Can these be related to Waistline?

davidhealey commented 10 months ago

Waistline doesn't make any requests to those urls

savchenko commented 10 months ago

Hmm... Is there an in-built debug facility to export logs without adb?

davidhealey commented 10 months ago

No you'll need to be running a debug build

savchenko commented 10 months ago

I wonder if this might be a limiting issue. Looking further, OpenFoodFacts export their DB and publish deltas daily: https://world.openfoodfacts.org/data

Perhaps it can be sync'd locally? Large one-time download, but enables 100% offline search.

davidhealey commented 10 months ago

How big is the DB?

savchenko commented 10 months ago

~700mb initial download. Also, searching at OpenFoodFacts directly returns an error as well:

image

Which strongly suggests that this has nothing to do with the Waistline, but an upstream issue.

davidhealey commented 10 months ago

700MB is too chunky to include in the app but maybe an option to download the DB locally could be added. I also assume that it would be possible to narrow the DB by region which would reduce the size.

savchenko commented 10 months ago

Indeed, this should be triggered from UI.

Regarding the region, https://openfoodfacts.github.io/openfoodfacts-server/api/ref-v2/#get-/api/v2/search has countries_tags_en to narrow-down the search, however I don't see it available for data exports and they explicitly discourage scraping of the DB via API.

@teolemon, could you please comment on this one? Summary: in this issue we investigate how to work around situations when OpenFoodFacts is returning an error and possibility of caching the DB locally.

teolemon commented 10 months ago

The MongoDB is down at the moment. We're working on it. Caching could be an option, we're doing it for the official mobile app in Flutter, but then you need to build a refresh mechanism.

CharlesNepote commented 10 months ago

There are different ways to reuse and filter Open Food Facts data, see https://wiki.openfoodfacts.org/Reusing_Open_Food_Facts_Data

Depending on your needs, you can build your own filters with different techniques:

teolemon commented 8 months ago

We have a new search API: https://search.openfoodfacts.org/docs

fs-99 commented 7 months ago

Any idea why search does not work at all? (other than already used entries)

davidhealey commented 7 months ago

Any idea why search does not work at all? (other than already used entries)

Is your internet turned on?

EmilJunker commented 7 months ago

Any idea why search does not work at all? (other than already used entries)

Is your internet turned on?

Also note that you have to press Enter after typing in the search term to perform an online search.

fs-99 commented 7 months ago

It just says "No matching results" instantly. I do use a DNS server setup which blocks some sites, so I will test on a relatives phone too now, then update this comment. Version 3.7.3, Android 7.0 does not work

edit: relatives phone works, same DNS setup but fairly new Android version, same waistline version but installed from playstore instead of fdroid I tried reinstalling waistline, did not change a thing.

Olangu commented 5 months ago

It's a real pain that searching openfoodfacts does not time out. They've recently had a few longer service windows. And if you're in the middle of adding a whole lot of entries to your meal you're really f---ed if you scan a label and are hung on the spinner. Need to stop rhe app and start from the beginning.

Would be nice to detect network problems too, I've had the problem that search returns nothing on a barcode scan. But as discussed in the thread, if I turn on wifi the same scan works. Would be a huge improvement if we'd get proper infoemation on errors.

This also applies to adding food to open food facts.

EmilJunker commented 5 months ago

@Olangu Do you already have the just released version 3.8.0 or are you still on an older version of Waistline? The latest release contains fixes for the exact problems you are describing, see pull request #788.

Olangu commented 5 months ago

@Olangu Do you already have the just released version 3.8.0 or are you still on an older version of Waistline? The latest release contains fixes for the exact problems you are describing, see pull request #788.

It's not yet available on FDroid. So no. I guess I'll have to wait. Thanks for the information.