aabu4537 / Team3-Recitation13

2 stars 0 forks source link

GET /filter #35

Closed EricGraham7 closed 2 years ago

EricGraham7 commented 2 years ago

As a user, I want be able to see all of the recipes that match the filters that I select on the home page.

User Acceptance Criteria: This API call should build a query according to the JSON object that captures the user's input that returns to the HTML a result object with only what the user was looking for.

EricGraham7 commented 2 years ago

This is probably the most complicated API call.

Will render the HTML page filter.ejs with a results JSON object containing all recipes that match the filters that the user inputted on the form in home.ejs.

Need from HTML: HTML needs to send values for cuisine_type and all of the columns under "filters" the items sent can be empty, (in fact most of the time there will be some empty) but they should still be sent. for example, in the login POST, it sends an email, but if the user provided no email, it would be empty. This is ok.

(To be explicit, I need cuisine_type, and all the booleans for: vegan, vegetarian, keto, paleo, grain_free, gluten_free, contains_dairy, contains_eggs, contains_nuts, contains_soy, contains_wheat, contains_beef, contains_pork, contains_fish, and the booleans (any amount of them can be true) for under_30_minutes, m30_minutes_1_hour, h1_hour_2_hours, h2_hours_3_hours, h3_hours_or_more and the booleans (any amount of them can be true) for s1_star, s2_stars, s3_stars, s4_stars, s5_stars Note: This time, sending one star_rating instead of the 5 different star booleans will not suffice, because the user should be able to filter for all recipes that are 3 or 4 stars, for example, and sending one value cannot convey this)

Return to HTML: Will return a JSON object called results (for use on the filter.ejs page) results will contain MULTIPLE (an array of) recipes, and for each one, you will be able to access ALL of its information just like the recipes table (except as a JSON object of course)

(To be explicit, for each recipe in the JSON object, it will have: recipe_id, recipe_name, prep_time, cook_time, recipe_image(a link), recipe_ingredients, instructions, cuisine_type, rating, date_published(format?), and the booleans for vegan, vegetarian, keto, paleo, grain_free, gluten_free, contains_dairy, contains_eggs, contains_nuts, contains_soy, contains_wheat, contains_beef, contains_pork, contains_fish, and the booleans for under_30_minutes, m30_minutes_1_hour, h1_hour_2_hours, h2_hours_3_hours, h3_hours_or_more and the booleans for s1_star, s2_stars, s3_stars, s4_stars, s5_stars)

Suggestions: if you want to display all of the information for each recipe, you will need to use ALL of these except recipe_id if you don't need to display all of the information for each recipe, you can simply use whatever you need. if you wanted to, you could try to find a way to display a bunch of recipes as cards, and then when you click on one, it gives you a popup which shows all of the information. I don't know how difficult this would be.