faker-js / faker

Generate massive amounts of fake data in the browser and node.js
https://fakerjs.dev
Other
12.85k stars 917 forks source link

Add food module on faker 🍽 #1593

Closed iliasmentz closed 9 months ago

iliasmentz commented 1 year ago

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

Shinigami92 commented 1 year ago

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

Shinigami92 commented 1 year ago

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

iliasmentz commented 1 year ago

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 commented 1 year ago

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

iliasmentz commented 1 year ago

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

From this, I would definitely use:

In the future, I could see myself also using:

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 commented 1 year ago

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 commented 1 year ago

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

ST-DDT commented 1 year ago

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 commented 1 year ago

Testing CRM and POS for a restaurant

ST-DDT commented 1 year ago

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

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?

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 https://github.com/faker-js/faker/issues/1593#issuecomment-1379526156). Sure, it looses some consistency, but that is acceptable IMO.

matthewmayer commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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

github-actions[bot] commented 1 year ago

Thank you for your feature proposal.

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

ShivamJoker commented 1 year ago

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 commented 1 year ago

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

matthewmayer commented 1 year ago

This issue now has 10 upvotes on the top and 19 on this child comment https://github.com/faker-js/faker/issues/1593#issuecomment-1535827963 - can we consider working on this for 8.x?

matthewmayer commented 1 year ago

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 commented 1 year ago

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

ST-DDT commented 1 year ago

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
}

If you have different suggestions please let us know.

Shinigami92 commented 1 year ago

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

xDivisionByZerox commented 1 year ago

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.