forked from DHBW-FN-TIT20/essensfindung
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'DHBW-FN-TIT20:main' into Implementation-Recipe-Frontend
- Loading branch information
Showing
31 changed files
with
842 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
data/recipeitems.json filter=lfs diff=lfs merge=lfs -text |
Git LFS file not shown
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from datetime import timedelta | ||
from typing import Optional | ||
|
||
from pydantic import BaseModel | ||
|
||
|
||
class Recipe(BaseModel): | ||
id: str | ||
name: str | ||
ingredients: str | ||
url: str | ||
image: Optional[str] | ||
cookTime: Optional[timedelta] | ||
prepTime: Optional[timedelta] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import pandas | ||
|
||
from schemes.scheme_filter import FilterRecipe | ||
from schemes.scheme_recipe import Recipe | ||
from tools.recipe_db import recipe_db | ||
from tools.recipe_db import RecipeDB | ||
|
||
|
||
def search_recipe(recipe_filter: FilterRecipe) -> Recipe: | ||
"""Search for a recipe with the given filter | ||
Args: | ||
recipe_filter (FilterRecipe): Filter the Recipes | ||
Returns: | ||
Recipe: The one choosen Recipe | ||
""" | ||
random_recipe: pandas.DataFrame = __apply_filter(recipe_db.pd_frame, recipe_filter).sample() | ||
|
||
return Recipe( | ||
id=random_recipe["_id.$oid"][0], | ||
name=random_recipe["name"][0], | ||
ingredients=random_recipe["ingredients"][0], | ||
url=random_recipe["url"][0], | ||
image=random_recipe["image"][0], | ||
cookTime=random_recipe["cookTime"][0], | ||
prepTime=random_recipe["prepTime"][0], | ||
) | ||
|
||
|
||
def __apply_filter(recipes: pandas.DataFrame, recipe_filter: FilterRecipe) -> pandas.DataFrame: | ||
cooktime_bool = RecipeDB.filter_cooktime(user_pd_frame=recipes, total_time=recipe_filter.total_time) | ||
keyword_bool = RecipeDB.filter_keyword(user_pd_frame=recipes, keyword=recipe_filter.keyword) | ||
|
||
filter_bool = cooktime_bool & keyword_bool | ||
return recipes[filter_bool] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/******** inititialize star-rating-svg *****************/ | ||
$("#rating_edit_rating").raty({ | ||
starOff: 'https://cdn.jsdelivr.net/npm/[email protected]/lib/images/star-off.png', | ||
starOn: 'https://cdn.jsdelivr.net/npm/[email protected]/lib/images/star-on.png', | ||
click: function(score, evt) { | ||
document.getElementById('rating_edit_rating_target').value = score; | ||
}, | ||
score: function() { | ||
return document.getElementById('rating_edit_rating_target').value; | ||
} | ||
}); |
Oops, something went wrong.