-
Notifications
You must be signed in to change notification settings - Fork 0
/
filter.js
100 lines (91 loc) · 2.52 KB
/
filter.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
module.exports = {
getFilterQuery: function(request){
var rtnString ="";
if(!!request.mealtime ){
switch(request.mealtime){
case "Frukost":
rtnString += " AND is_Breakfast = 1";
break;
case "Huvudrätt":
rtnString += "AND is_Maincourse = 1"
break;
case "Middag":
rtnString += "AND is_Dinner = 1"
break;
case "Efterrätt":
rtnString += "AND is_Desert = 1"
break;
}
}
if(!!request.diet){
switch(request.diet){
case "Vegan":
rtnString += " AND is_Vegan = 1";
break;
case "Glutenfri":
rtnString += " AND is_Glutenfree = 1";
break;
case "Vegterainsk":
rtnString += " AND is_Vegetarian = 1";
break;
case "Laktosfri":
rtnString += " AND is_Lactosefree = 1";
break;
}
}
if(!!request.time){
console.log("Time: " + request.time)
switch(request.time){
case "Under 15min":
rtnString += " AND time_duration = 15";
break;
case "Under 30min":
rtnString += " AND time_duration <= 30 ";
break;
case "Under 45min":
rtnString += " AND time_duration <= 45";
break;
case "Under 60min":
rtnString += " AND time_duration <= 60";
break;
case "Över 60min":
rtnString += " AND time_duration = 61 ";
break;
}
}
if(!!request.grade){
console.log("grade: " + request.grade)
switch(request.grade){
case "Mindre än 3":
rtnString += " AND rating <= 3";
break;
case "Mindre än 4":
rtnString += " AND rating <= 4";
break;
case "Högre än 4":
rtnString += " AND rating >= 4";
break;
case "5 sjärnor":
rtnString += " AND rating = 5";
break;
}
}
if(!!request.kcal){
switch(request.kcal){
case "Under 200 kcal":
rtnString += " AND kcal <= 200";
break;
case "Under 500 kcal":
rtnString += " AND kcal <= 500";
break;
case "Under 1000 kcal":
rtnString += " AND kcal <= 1000";
break;
}
}
if(request.climateSmart){
rtnString += " AND is_ClimateSmart = 1 ";
}
return rtnString;
}
};