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

Ingredients Endpoint - Embed Weight Units #411

Closed
GavinRay97 opened this issue Oct 31, 2017 · 1 comment
Closed

Ingredients Endpoint - Embed Weight Units #411

GavinRay97 opened this issue Oct 31, 2017 · 1 comment
Milestone

Comments

@GavinRay97
Copy link

GavinRay97 commented Oct 31, 2017

Hi, I want to thank you guys for the all work you've done in creating such a great open-source service, but one of the biggest hurdles towards use of the API currently is the fact that the Ingredients endpoint returns values defaulted to 100g measurements, and in order to get to a human-readable form I have to find the ingredient ID via search, then perform a second query like:

https://wger.de/api/v2/ingredientweightunit/?format=json&ingredient=1074

And from the array of weight units returned, I have to query the weight units endpoint to get the human readable name.

I spent last night spinning up a Docker image, pruned all the languages but english, ran the manager script to generate the SQLite database, then converted the SQLite DB into a series of CSV files for each table, wrote a batch script to iterate over every file and use Mongo CLI to convert into a MongoDB collection and send to hosted mlab server, and then wrote Ruby models for them.

But still, to get the human-readable weight units from an Ingredient, I have to do something like this:

ingredient = NutritionIngredient.where(:name => /searchterm/).first
ingredient.ingredient_weights.each do |weight| return weight.weight_name

And the models/queries are not pretty:

Just

Could the weight units and names be embedded with the top-level ingredient object in the API please?

@rolandgeider
Copy link
Member

This is available on master on v2/ingredientinfo, similarly to v2/exerciseinfo, a read-only endpoint with nested serialization

@rolandgeider rolandgeider added this to the 2.0 milestone Nov 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants