started ignored tags
This commit is contained in:
parent
c77d835fa3
commit
5e34db5494
|
|
@ -7,7 +7,7 @@ import time
|
|||
import heapq
|
||||
from collections import Counter
|
||||
import background.migrate
|
||||
|
||||
from sqlalchemy import exists
|
||||
|
||||
def search2(inputArr):
|
||||
indx = {}
|
||||
|
|
@ -55,6 +55,12 @@ def getRecDict2(indx, inputArr):
|
|||
if i not in ingredDict[k]:
|
||||
ingredDict[k][i] = []
|
||||
ingredDict[k][i].append(v)
|
||||
|
||||
ignored = []
|
||||
for x in inputArr:
|
||||
if not dbSession.query(exists().where(db.Trunk.name == x)).scalar():
|
||||
ignored.append(x)
|
||||
|
||||
inputArr += defaultArr
|
||||
|
||||
# checks overlay per recipeID
|
||||
|
|
@ -67,6 +73,8 @@ def getRecDict2(indx, inputArr):
|
|||
overlay -= 0.0001
|
||||
outDict[overlay] = (int(key), missing)
|
||||
|
||||
|
||||
|
||||
# return Dict with 20 highest value keys
|
||||
outDict2 = {}
|
||||
for key in heapq.nlargest(20, outDict.keys()):
|
||||
|
|
@ -76,7 +84,10 @@ def getRecDict2(indx, inputArr):
|
|||
db.Recipe.recipe_id == key2).first()
|
||||
outDict2[key] = (key2, rec.name, rec.url, [r[0] + ": " + r[1] for r in dbSession.query(db.Ingredient.name,
|
||||
db.RecIngred.ingredient_amount).join(db.RecIngred).join(db.Recipe).filter(db.Recipe.recipe_id == key2).all()], missing)
|
||||
return outDict2
|
||||
outDict = {}
|
||||
outDict["ignored"] = ignored
|
||||
outDict["ingred"] = outDict2
|
||||
return outDict
|
||||
|
||||
|
||||
def stem(l1):
|
||||
|
|
|
|||
|
|
@ -35,10 +35,13 @@ function loadRecipes(getParams){
|
|||
|
||||
getJSON("/api/v1/recipe/" + getParams,
|
||||
function (error, data) {
|
||||
data = data["data"] // remove wrapper
|
||||
console.log(data)
|
||||
ignored = data["data"]["ignored"]
|
||||
data = data["data"]["ingred"] // remove wrapper
|
||||
|
||||
|
||||
renderRecipeList(data)
|
||||
|
||||
renderIgnored(ignored)
|
||||
},
|
||||
function (error, data) {
|
||||
console.log(error)
|
||||
|
|
@ -47,6 +50,25 @@ function loadRecipes(getParams){
|
|||
}
|
||||
);
|
||||
}
|
||||
function renderIgnored(ignored){
|
||||
document.getElementById("search-form").innerHTML += "<br>"
|
||||
ignored.forEach(
|
||||
function (item, index) {
|
||||
document.getElementById("search-form").innerHTML += `<span class="badge badge-danger badge-pill">${item}</span>`
|
||||
}
|
||||
)
|
||||
let url = window.location.href
|
||||
params = url.split("?")[1]
|
||||
if (params !== undefined){
|
||||
// url param to string for search bar
|
||||
paramString = params.split("&").join("").split("ingred=").join(", ").replace(", ", "")
|
||||
|
||||
document.getElementById("search-field").value = paramString
|
||||
params = "?" + params
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function makeGetParamString(){
|
||||
searchString = document.getElementById("search-field").value
|
||||
|
|
@ -77,6 +99,9 @@ function renderRecipeList(data){
|
|||
missingString = ""
|
||||
data1[3].forEach(
|
||||
function(ingred){
|
||||
if (ingred.charAt(ingred.length-2) === ":"){
|
||||
ingred = ingred.substr(0, ingred.length-2)
|
||||
}
|
||||
ingredString += `${ingred}<br>`
|
||||
}
|
||||
)
|
||||
|
|
@ -84,7 +109,14 @@ function renderRecipeList(data){
|
|||
function(ingred){
|
||||
missingString += `${ingred}<br>`
|
||||
}
|
||||
)
|
||||
)
|
||||
if(data1[4].length === 0){
|
||||
missing = ""
|
||||
}
|
||||
else{
|
||||
missing = "<br>Fehlt:<br>"
|
||||
}
|
||||
|
||||
recString = `
|
||||
<div class="card text-white bg-primary mb-3" style="max-width: 100%">
|
||||
<div class="card-body recipe-container">
|
||||
|
|
@ -109,7 +141,7 @@ function renderRecipeList(data){
|
|||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<br>Fehlt:<br>
|
||||
${missing}
|
||||
<div class="recipe-ingredients missing">
|
||||
${missingString}
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in New Issue