nagasurendra commited on
Commit
438421a
·
verified ·
1 Parent(s): 3f67e98

Update menu.py

Browse files
Files changed (1) hide show
  1. menu.py +9 -4
menu.py CHANGED
@@ -6,6 +6,8 @@ menu_blueprint = Blueprint('menu', __name__)
6
  # Initialize Salesforce connection
7
  sf = get_salesforce_connection()
8
 
 
 
9
  @menu_blueprint.route("/menu", methods=["GET", "POST"])
10
  def menu():
11
  selected_category = request.args.get("category", "All")
@@ -137,8 +139,11 @@ def menu():
137
  addons = item_parts[1].strip().replace('Add-Ons:', '').split(', ')
138
  instructions = item_parts[2].strip().replace('Instructions:', '').split(', ')
139
 
 
 
 
140
  # Count occurrences for add-ons and instructions
141
- for addon in addons:
142
  if addon:
143
  addon_counts[addon] = addon_counts.get(addon, 0) + 1
144
 
@@ -146,8 +151,8 @@ def menu():
146
  if instruction:
147
  instruction_counts[instruction] = instruction_counts.get(instruction, 0) + 1
148
 
149
- # Print the add-ons and instructions to check what we're fetching
150
- print(f"Add-ons fetched: {addon_counts}")
151
  print(f"Instructions fetched: {instruction_counts}")
152
 
153
  # Get the most frequent add-ons and instructions
@@ -155,7 +160,7 @@ def menu():
155
  most_common_instructions = sorted(instruction_counts, key=instruction_counts.get, reverse=True)[:3] # Top 3 most frequent instructions
156
 
157
  # Print to check the final most common add-ons and instructions
158
- print(f"Most common add-ons: {most_common_addons}")
159
  print(f"Most common instructions: {most_common_instructions}")
160
 
161
  categories = ["All", "Veg", "Non veg"]
 
6
  # Initialize Salesforce connection
7
  sf = get_salesforce_connection()
8
 
9
+ import re # Importing regular expression module
10
+
11
  @menu_blueprint.route("/menu", methods=["GET", "POST"])
12
  def menu():
13
  selected_category = request.args.get("category", "All")
 
139
  addons = item_parts[1].strip().replace('Add-Ons:', '').split(', ')
140
  instructions = item_parts[2].strip().replace('Instructions:', '').split(', ')
141
 
142
+ # Clean the add-on names by removing any price information
143
+ cleaned_addons = [re.sub(r"\s?\(\$\d+(\.\d{2})?\)", "", addon) for addon in addons]
144
+
145
  # Count occurrences for add-ons and instructions
146
+ for addon in cleaned_addons:
147
  if addon:
148
  addon_counts[addon] = addon_counts.get(addon, 0) + 1
149
 
 
151
  if instruction:
152
  instruction_counts[instruction] = instruction_counts.get(instruction, 0) + 1
153
 
154
+ # Print the cleaned add-ons and instructions to check what we're fetching
155
+ print(f"Add-ons fetched (cleaned): {addon_counts}")
156
  print(f"Instructions fetched: {instruction_counts}")
157
 
158
  # Get the most frequent add-ons and instructions
 
160
  most_common_instructions = sorted(instruction_counts, key=instruction_counts.get, reverse=True)[:3] # Top 3 most frequent instructions
161
 
162
  # Print to check the final most common add-ons and instructions
163
+ print(f"Most common add-ons (cleaned): {most_common_addons}")
164
  print(f"Most common instructions: {most_common_instructions}")
165
 
166
  categories = ["All", "Veg", "Non veg"]