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

[RFC] Support for Open Food Facts variants #69

Closed
Tracked by #218
teolemon opened this issue Jan 21, 2021 · 5 comments
Closed
Tracked by #218

[RFC] Support for Open Food Facts variants #69

teolemon opened this issue Jan 21, 2021 · 5 comments
Labels
fixed ? 🧴 Open Beauty Facts Our cosmetic analysis project https://world.openbeautyfacts.org 🐾 Open Pet Food Facts Our pet food analysis project https://world.openpetfoodfacts.org 📸 Open Products Facts 🎯 P1

Comments

@teolemon
Copy link
Member

teolemon commented Jan 21, 2021

Request for comments:
Is there any way to add support for Open Food Facts variants such as ?

Is there a way to do it that would not break existing apps ? Or would we need to clone the package ?

@teolemon teolemon added the 🧴 Open Beauty Facts Our cosmetic analysis project https://world.openbeautyfacts.org label Jan 29, 2021
@monsieurtanuki
Copy link
Contributor

@teolemon I've just had a look at the names of the files in OFF-dart: the vast majority is definitely about food (for human beings).
I thin beauty/pet-food/products each deserve a separate dart project.

@teolemon teolemon changed the title [RFC] Support for Open Food Facts variant [RFC] Support for Open Food Facts variants Jun 9, 2023
@teolemon teolemon added 📸 Open Products Facts 🐾 Open Pet Food Facts Our pet food analysis project https://world.openpetfoodfacts.org 🎯 P1 labels Jun 9, 2023
@monsieurtanuki
Copy link
Contributor

@teolemon We now have a ServerType enum that would be helpful:

/// Type of Server (e.g. "food facts", "beauty facts", ...).
enum ServerType implements OffTagged {
  /// Open Food Facts
  openFoodFacts(offTag: 'off'),
  /// Open Beauty Facts
  openBeautyFacts(offTag: 'obf'),
  /// Open Pet Food Facts
  openPetFoodFacts(offTag: 'opff'),
  /// Open Product Facts
  openProductFacts(offTag: 'opf');
  const ServerType({
    required this.offTag,
  });
  @override
  final String offTag;
}

In off-dart this is how we compute the URLs:

        host: OpenFoodAPIConfiguration.getQueryType(queryType) == QueryType.PROD
            ? OpenFoodAPIConfiguration.uriProdHost // for the moment, 'world.openfoodfacts.org'
            : OpenFoodAPIConfiguration.uriTestHost, // for the moment, 'world.openfoodfacts.net'

We could add a ServerType parameter to get an easy access to other servers

I don't think it makes much sense maintaining two variables for the host (uriProdHost, uriTestHost) as nobody uses both at the same time.
I guess we would be better off with one variable (e.g. host) and 2 methods:

  • setForcedHost(final String host) that would force the host to a specific value - e.g. for custom servers
  • setHost(final QueryType queryType, final ServerType serverType) for "normal" use - e.g. I'm using open beauty facts on PROD

That would mean a (minor) breaking change.

@monsieurtanuki
Copy link
Contributor

Actually we can already point to open beauty facts today by changing OpenFoodAPIConfiguration.uriProdHost.
Would beauty product data fit in a food product data template? Probably not, and we need specs for that.

@teolemon
Copy link
Member Author

teolemon commented Dec 6, 2024

@monsieurtanuki I believe we can close this

@monsieurtanuki
Copy link
Contributor

@teolemon As long as products have the same structure in all servers, yes we can.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed ? 🧴 Open Beauty Facts Our cosmetic analysis project https://world.openbeautyfacts.org 🐾 Open Pet Food Facts Our pet food analysis project https://world.openpetfoodfacts.org 📸 Open Products Facts 🎯 P1
Development

No branches or pull requests

2 participants