Skip to content

Add food module on faker 🍽 #1593

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

Closed
iliasmentz opened this issue Nov 23, 2022 · 23 comments · Fixed by #2484
Closed

Add food module on faker 🍽 #1593

iliasmentz opened this issue Nov 23, 2022 · 23 comments · Fixed by #2484
Assignees
Labels
c: feature Request for new feature p: 1-normal Nothing urgent s: accepted Accepted feature / Confirmed bug
Milestone

Comments

@iliasmentz
Copy link

iliasmentz commented Nov 23, 2022

Clear and concise description of the problem

As a developer using faker I want to be able to generate fake food data. That would allow food/restaurant-focused companies to create more accurate test environments faster.

Suggested solution

We could reuse the data from the original faker (ruby) library:
https://github.com/faker-ruby/faker/blob/main/lib/locales/en/food.yml

Alternative

No response

Additional context

I would be happy to attempt to pick this up, but in the CONTRIBUTING.md file it's a bit unclear how you can add a new module

@iliasmentz iliasmentz added the s: pending triage Pending Triage label Nov 23, 2022
@iliasmentz iliasmentz changed the title Add food faker Add food module on faker 🍽 Nov 23, 2022
@Shinigami92
Copy link
Member

I like the idea, but would remove or handle some data differently
The team should talk about this in a meeting first

@Shinigami92 Shinigami92 added the s: needs decision Needs team/maintainer decision label Nov 23, 2022
@ejcheng ejcheng added c: feature Request for new feature and removed s: pending triage Pending Triage labels Nov 23, 2022
@Shinigami92
Copy link
Member

@iliasmentz Do you actually need it for your work/project, or is it just a feature request you consider useful?

@Shinigami92 Shinigami92 added s: awaiting more info Additional information are requested s: waiting for user interest Waiting for more users interested in this feature p: 1-normal Nothing urgent and removed s: needs decision Needs team/maintainer decision labels Nov 24, 2022
@Shinigami92 Shinigami92 added this to the vFuture milestone Nov 24, 2022
@iliasmentz
Copy link
Author

Thanks for following up @Shinigami92. We already use fakerjs in our project for test data but for now we have to use the commerce module result to a less realistic dataset. So the answer is yes 😄

@ST-DDT
Copy link
Member

ST-DDT commented Nov 24, 2022

@iliasmentz Which of the ruby faker food datasets/lists are useful to you and which not?

@iliasmentz
Copy link
Author

Apologies for the delay @ST-DDT , I was off for a few days.

From this, I would definitely use:

  • Dish
  • Descriptions
  • Ingredients
  • Ethnic categories

In the future, I could see myself also using:

  • measurements
  • metric_measurements

the rest are less likely to be used (from me at least) as I feel the ingredients could cover them. they might be used for something particular but I can't really think of an actual use case right now.

hope that helps 😅

@matthewmayer
Copy link
Contributor

matthewmayer commented Jan 11, 2023

I also had a recent need for a food (and drink) module. I would agree that dishes are most important. Might be good to seperate types of dish, like main courses, desserts, drinks. If we did dishes with descriptions then i'd prefer if you got back a {name, description} object rather than the description being completely unrelated to the name.

http://menus.nypl.org/ has some good historical data which perhaps we could utilize.

One thing i dont like about the Ruby data is the dish names are unrealistically simple/short, whereas in reality its common to have some longer dish names mixed in.

thought this was quite interesting too! https://www.restaurant-website-builder.com/restaurant-menu-descriptions

@matthewmayer
Copy link
Contributor

Dietary restrictions for each menu item could also be useful, e.g. Vegetarian, Gluten-free, Contains Nuts

@ST-DDT
Copy link
Member

ST-DDT commented Jan 11, 2023

Dietary restrictions for each menu item could also be useful, e.g. Vegetarian, Gluten-free, Contains Nuts

What is your usecase for that for test data?
On a real website this makes sense, but we only deliver test data, our filter criteria are very likely to be different from the actual website so users either have to map the filter criteria or just randomly assign their attributes to our names.

e.g.

{
  fruit-salat: {
    containsNuts: true, 
    containsGluten: true, 
    containsLactose: true, 
    vegan: true, 
    vegentarian: false
  }
}

created via something like this:

menu[faker.food.food()] = { 
    containsNuts: faker.datatype.boolean(),
    containsGluten: faker.datatype.boolean(),
    containsLactose: faker.datatype.boolean(),
    vegan: faker.datatype.boolean(),
    vegentarian: faker.datatype.boolean()
};

@matthewmayer
Copy link
Contributor

Testing CRM and POS for a restaurant

@ST-DDT
Copy link
Member

ST-DDT commented Jan 12, 2023

I'm not sure what exactly you are referring to/hinting at.

  • CRM = Customer Relationship Management
  • POS = Point of Sale

I have no problem including the names of food (or names of ingredients), but I'm not so sure about including its ingredients or special properties of that food in it.

There is a reason why we mostly abandoned complex return objects: The data structures that we have provided before differ from those that the user needs. The same applies to foods as well, so I would like to know an exact usecase for it.

IMO if the UI shows a food-name as "Fruid-Salad" and lists it's ingredients as "Fish" and "Salt" and displays it as "Vegan", then that could be OK for testing purposes.

If we provide these information as well, then what about a recipe website that need the actual quantities of those ingredients.

Where do we stop with the data?

  • Should we order the ingredients by importance, by quantity, by name?
  • All ingredients or only the main ones?
  • What about spices?
  • What about calories?
  • What about meal sizes? Children-Size, Normal, XXL
  • What about food additives such as E123?
  • Should we include vegetarian/vegan/xyz-an information?
  • Should we include allergy information?
  • What about the food description? e.g. Grilled steak with mashed potatoes and green salad
  • What about an image of the food?
  • Should we include different variations? e.g. with fries or rice or standalone?

IMO it is not important whether these things are correct for testing purposes as long as the user can generate the data however they need it (e.g. like #1593 (comment)). Sure, it looses some consistency, but that is acceptable IMO.

@matthewmayer
Copy link
Contributor

just brainstorming. you could probably limit it initially to

faker.food.dish(type) (type=dessert, main, drink) // returns {name, description}
faker.food.ingredients({min, max}) // returns an array with between min and max ingredients

as you say other things are too menu-specific, and can be easily done with booleans (is is vegetarian) or ints (how many calories)

@matthewmayer
Copy link
Contributor

or if you want to avoid returned objects completely then split faker.food.dish and faker.food.dishDescription and accept it will be inconsistent

@iliasmentz
Copy link
Author

that's a very interesting discussion 🙌
After working on ordering systems for a while, I would argue that if we are going to a more complex dataset that could be restaurant oriented, it would make more sense to have sides (e.g. fries, rice, salad) and options (rare, medium-rare, etc) instead of ingredients.

Ingredients focus more on storage management but as @ST-DDT said if we want a simple dataset both of them are not really that vital, we can build that on our end even if it looks like:

Fruid-Salad" and lists it's ingredients as "Fish" and "Salt" and displays it as "Vegan"

Finally regardless of what faker would offer, if I needed a custom logic for restrictions I would probably have them as an enum on my side instead of using faker's ones.

@matthewmayer
Copy link
Contributor

also wondering what the module name should be, if it also includes say drinks then food is not accurate. Could be faker.restaurant.*

@ST-DDT ST-DDT added s: waiting for user interest Waiting for more users interested in this feature and removed s: waiting for user interest Waiting for more users interested in this feature labels May 5, 2023
@github-actions
Copy link
Contributor

github-actions bot commented May 5, 2023

Thank you for your feature proposal.

We marked it as "waiting for user interest" for now to gather some feedback from our community:

  • If you would like to see this feature be implemented, please react to the description with an up-vote (:+1:).
  • If you have a suggestion or want to point out some special cases that need to be considered, please leave a comment, so we are aware about them.

We would also like to hear about other community members' use cases for the feature to give us a better understanding of their potential implicit or explicit requirements.

We will start the implementation based on:

  • the number of votes (:+1:) and comments
  • the relevance for the ecosystem
  • availability of alternatives and workarounds
  • and the complexity of the requested feature

We do this because:

  • There are plenty of languages/countries out there and we would like to ensure that every method can cover all or almost all of them.
  • Every feature we add to faker has "costs" associated to it:
    • initial costs: design, implementation, reviews, documentation
    • running costs: awareness of the feature itself, more complex module structure, increased bundle size, more work during refactors

View more issues which are waiting for user interest

@ShivamJoker
Copy link

I'd love this feature.
I've collected a lot of data from Wikipedia on breads, fishes, fruits, pastas, veggies, potatoes, mangoes etc.
If you'd like me to contribute - I'm down!

@Shinigami92
Copy link
Member

This Module got more then 5 upvotes! 🎉
Therefore we will accept and work on this module ❤️

@Shinigami92 Shinigami92 added s: accepted Accepted feature / Confirmed bug and removed s: awaiting more info Additional information are requested s: waiting for user interest Waiting for more users interested in this feature labels Jul 17, 2023
@Shinigami92 Shinigami92 moved this to Todo in Faker Roadmap Jul 17, 2023
@matthewmayer
Copy link
Contributor

This issue now has 10 upvotes on the top and 19 on this child comment #1593 (comment) - can we consider working on this for 8.x?

@matthewmayer
Copy link
Contributor

matthewmayer commented Oct 11, 2023

It would be nice if you have building blocks which allow for more creative dish names than just a hardcoded list, for example

faker.food.dish() could pick from a series of fake patterns like

'{{faker.food.cookingStyle}} {{faker.food.protein}} with {{faker.food.vegetable}}'

Which then gives you e.g. "fried chicken with broccoli" or "steamed tofu with spring onions"

@xDivisionByZerox xDivisionByZerox modified the milestones: vFuture, vAnytime Oct 11, 2023
@xDivisionByZerox
Copy link
Member

I move this to the Anytime milestone. We should discuss the API in the next meeting before starting to implement.

@ST-DDT
Copy link
Member

ST-DDT commented Oct 17, 2023

Team Decision

We will start with a MVP:

class FoodModule {
    dish(): plain.string; // fried chicken
    description(): fake.string; // Three eggs with cilantro, tomatoes, onions, avocados and melted Emmental cheese. With a side of roasted potatoes, and your choice of toast or croissant.
    ingedient(): plain.string; // egg
    ethnicCategory(): plain.string; // Italian
    fruit(): plain.string; // apple
    vegetable(): plain.string; // carrot
    spice(): plain.string; // pepper
}
  • plain.string refers to faker.helpers.arrayElement
  • fake.string refers to faker.helpers.fake

If you have different suggestions please let us know.

@Shinigami92
Copy link
Member

ingedient -> ingredient
ethnicCategory -> kitchenStyle/kitchenCategory (?)
(food)Category (? https://wolt.com/en/discovery/restaurants)

@xDivisionByZerox
Copy link
Member

I've created #2484 as an MVP for this. If you want to participate in designing the API please feel free to leave a comment on the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: feature Request for new feature p: 1-normal Nothing urgent s: accepted Accepted feature / Confirmed bug
Projects
No open projects
Status: Todo
Development

Successfully merging a pull request may close this issue.

7 participants