elli-teu commited on
Commit
0e5d426
·
1 Parent(s): 56da4fc

Påbörjat projekt tillagad mat

Browse files
pages/dish_planning.py CHANGED
@@ -12,7 +12,7 @@ st.write("Welcome to the dish planning page!")
12
  # st.write(f"user id: {u}, i: {i}")
13
  # for i in user_list[u][i]:
14
  # st.write(i)
15
-
16
 
17
  col1, col2 = st.columns(2)
18
  with col1:
@@ -33,6 +33,37 @@ with col1:
33
  found = True
34
  break
35
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  if allergic_people_count > 0:
37
  st.write(f"{i} - {allergic_people_count} guest{'s are' if allergic_people_count > 1 else ' is'} sensitive to this ingredient")
38
  else:
@@ -78,6 +109,53 @@ with col2:
78
 
79
  st.write(f"In total, {total_affected_guests} {'is' if total_affected_guests == 1 else 'are'} unable to eat this dish.")
80
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
81
 
82
  # Text input for the search query
83
  query = st.text_input("Search for an ingredient:")
@@ -88,14 +166,25 @@ if query:
88
  else:
89
  filtered_items = allergens
90
 
 
 
 
 
91
  # Display the filtered list
92
  st.write("Results:")
93
  for item in filtered_items:
94
  if item in ingredient_list:
95
  if st.button(f"- {item} (this is in your food)"):
96
  ingredient_list.remove(item)
 
97
  st.rerun()
 
 
 
 
 
98
  else:
99
  if st.button(f"- {item}"):
100
  ingredient_list.append(item)
 
101
  st.rerun()
 
12
  # st.write(f"user id: {u}, i: {i}")
13
  # for i in user_list[u][i]:
14
  # st.write(i)
15
+ #Behöver lägga till om den tillagas eller ej?
16
 
17
  col1, col2 = st.columns(2)
18
  with col1:
 
33
  found = True
34
  break
35
 
36
+ if allergic_people_count > 0:
37
+ st.write(f"{i} - {allergic_people_count} guest{'s are' if allergic_people_count > 1 else ' is'} sensitive to this ingredient")
38
+
39
+ else:
40
+ st.write(f"{i}")
41
+ st.header("Ingredients2")
42
+ for i in ingredients_list.keys():
43
+ allergic_people_count = 0
44
+ for u in user_list.values():
45
+ if i in u.keys():
46
+ if ingredients_list[i] == False: #Raw, does not matter if the guest can eat it cooked
47
+ allergic_people_count += 1
48
+ else:
49
+ if u[i][1] == False: #The ingredient is cooked but the guest can still not eat it
50
+ allergic_people_count += 1
51
+ else:
52
+ found = False
53
+ for s in synonyms[i]:
54
+ if found:
55
+ break
56
+ else:
57
+ if s in u.keys():
58
+ if ingredients_list[i] == False: #Raw, does not matter if the guest can eat it cooked
59
+ allergic_people_count += 1
60
+ else:
61
+ if u[s][1] == False: #The ingredient is cooked but the guest can still not eat it
62
+ allergic_people_count += 1
63
+ #allergic_people_count += 1
64
+ found = True
65
+ break
66
+
67
  if allergic_people_count > 0:
68
  st.write(f"{i} - {allergic_people_count} guest{'s are' if allergic_people_count > 1 else ' is'} sensitive to this ingredient")
69
  else:
 
109
 
110
  st.write(f"In total, {total_affected_guests} {'is' if total_affected_guests == 1 else 'are'} unable to eat this dish.")
111
 
112
+ st.header("Aggregate 2:")
113
+ user_pools = defaultdict(lambda: False)
114
+
115
+ # Summary of allergies
116
+ for user_id in user_list.keys():
117
+ relevant_allergy_list = ""
118
+ for ingredient in ingredient_list:
119
+ if ingredient in user_list[user_id].keys():
120
+ if not ingredients_list[ingredient]: #Raw
121
+ if relevant_allergy_list == "":
122
+ relevant_allergy_list = relevant_allergy_list + ingredient
123
+ else:
124
+ relevant_allergy_list = relevant_allergy_list + ", " + ingredient
125
+ else:
126
+ if not user_list[user_id][1]: #cooked, but can still not eat
127
+ if relevant_allergy_list == "":
128
+ relevant_allergy_list = relevant_allergy_list + ingredient
129
+ else:
130
+ relevant_allergy_list = relevant_allergy_list + ", " + ingredient
131
+
132
+ else:
133
+ for s in synonyms[i]:
134
+ found = False
135
+ if found:
136
+ break
137
+ else:
138
+ if s in user_list[user_id].keys():
139
+ if relevant_allergy_list == "":
140
+ relevant_allergy_list = relevant_allergy_list + ingredient
141
+ else:
142
+ relevant_allergy_list = relevant_allergy_list + ", " + ingredient
143
+ found = True
144
+ break
145
+ if not relevant_allergy_list == "":
146
+ if not user_pools[relevant_allergy_list]:
147
+ user_pools[relevant_allergy_list] = 1
148
+ else:
149
+ user_pools[relevant_allergy_list] += 1
150
+
151
+ total_affected_guests = 0
152
+ for pool in user_pools.keys():
153
+ #relevant_allergies = pool.split(",")
154
+ st.write(f"{user_pools[pool]} user{'s' if user_pools[pool] == 1 else ''} cannot eat {pool}")
155
+ total_affected_guests += user_pools[pool]
156
+
157
+ st.write(f"In total, {total_affected_guests} {'is' if total_affected_guests == 1 else 'are'} unable to eat this dish.")
158
+
159
 
160
  # Text input for the search query
161
  query = st.text_input("Search for an ingredient:")
 
166
  else:
167
  filtered_items = allergens
168
 
169
+ def update_cook(item):
170
+ prev = ingredients_list[item]
171
+ ingredients_list[item] = not prev
172
+
173
  # Display the filtered list
174
  st.write("Results:")
175
  for item in filtered_items:
176
  if item in ingredient_list:
177
  if st.button(f"- {item} (this is in your food)"):
178
  ingredient_list.remove(item)
179
+ ingredients_list.pop(item)
180
  st.rerun()
181
+ if_cooked = st.checkbox(
182
+ "The ingredient will be cooked",
183
+ key=f"{item}_cooked",
184
+ on_change=lambda item=item: update_cook(item)
185
+ )
186
  else:
187
  if st.button(f"- {item}"):
188
  ingredient_list.append(item)
189
+ ingredients_list[item] = False
190
  st.rerun()
utils/__pycache__/allergy_input.cpython-312.pyc CHANGED
Binary files a/utils/__pycache__/allergy_input.cpython-312.pyc and b/utils/__pycache__/allergy_input.cpython-312.pyc differ
 
utils/__pycache__/variables.cpython-312.pyc CHANGED
Binary files a/utils/__pycache__/variables.cpython-312.pyc and b/utils/__pycache__/variables.cpython-312.pyc differ
 
utils/variables.py CHANGED
@@ -1,6 +1,7 @@
1
  from collections import defaultdict
2
 
3
  ingredient_list = []
 
4
 
5
  # Init user profiles
6
 
 
1
  from collections import defaultdict
2
 
3
  ingredient_list = []
4
+ ingredients_list = defaultdict(lambda: (False)) #Funkar detta?
5
 
6
  # Init user profiles
7