Spaces:
Sleeping
Sleeping
Update menu.py
Browse files
menu.py
CHANGED
@@ -78,7 +78,7 @@ def fetch_menu_data(selected_category, user_email):
|
|
78 |
SELECT Name, Price__c, Description__c, Image1__c, Image2__c,
|
79 |
Veg_NonVeg__c, Section__c, Total_Ordered__c
|
80 |
FROM Custom_Dish__c
|
81 |
-
WHERE CreatedDate >= LAST_N_DAYS:7
|
82 |
"""
|
83 |
custom_dish_result = sf.query_all(custom_dish_query)
|
84 |
custom_dishes = custom_dish_result.get('records', [])
|
@@ -134,7 +134,7 @@ def fetch_menu_data(selected_category, user_email):
|
|
134 |
SELECT Order_Details__c FROM Order__c
|
135 |
WHERE Customer_Email__c = '{user_email}'
|
136 |
"""
|
137 |
-
past_orders_result = sf.
|
138 |
past_orders = past_orders_result.get('records', [])
|
139 |
|
140 |
# Frequency analysis for add-ons and instructions
|
@@ -162,6 +162,8 @@ def fetch_menu_data(selected_category, user_email):
|
|
162 |
# Get most common add-ons and instructions (top 3)
|
163 |
most_common_addons = sorted(addon_counts, key=addon_counts.get, reverse=True)[:3]
|
164 |
most_common_instructions = sorted(instruction_counts, key=instruction_counts.get, reverse=True)[:3]
|
|
|
|
|
165 |
|
166 |
return ordered_menu, referral_code, reward_points, cart_item_count, most_common_addons, most_common_instructions
|
167 |
|
@@ -305,7 +307,7 @@ def add_to_cart():
|
|
305 |
FROM Cart_Item__c
|
306 |
WHERE Customer_Email__c = '{customer_email}' AND Name = '{item_name}'
|
307 |
"""
|
308 |
-
result = sf.
|
309 |
cart_items = result.get("records", [])
|
310 |
|
311 |
addons_price = sum(float(addon.get('price', 0)) for addon in addons)
|
@@ -367,6 +369,7 @@ def add_to_cart():
|
|
367 |
return jsonify({"success": True, "message": "Item added to cart successfully.", "cart": cart})
|
368 |
|
369 |
except ValueError as e:
|
|
|
370 |
return jsonify({"success": False, "error": f"Invalid data format: {str(e)}"}), 400
|
371 |
except Exception as e:
|
372 |
print(f"Error adding item to cart: {str(e)}")
|
|
|
78 |
SELECT Name, Price__c, Description__c, Image1__c, Image2__c,
|
79 |
Veg_NonVeg__c, Section__c, Total_Ordered__c
|
80 |
FROM Custom_Dish__c
|
81 |
+
WHERE CreatedDate >= LAST_N_DAYS:7 AND Total_Ordered__c > 10
|
82 |
"""
|
83 |
custom_dish_result = sf.query_all(custom_dish_query)
|
84 |
custom_dishes = custom_dish_result.get('records', [])
|
|
|
134 |
SELECT Order_Details__c FROM Order__c
|
135 |
WHERE Customer_Email__c = '{user_email}'
|
136 |
"""
|
137 |
+
past_orders_result = sf.query_all(past_orders_query)
|
138 |
past_orders = past_orders_result.get('records', [])
|
139 |
|
140 |
# Frequency analysis for add-ons and instructions
|
|
|
162 |
# Get most common add-ons and instructions (top 3)
|
163 |
most_common_addons = sorted(addon_counts, key=addon_counts.get, reverse=True)[:3]
|
164 |
most_common_instructions = sorted(instruction_counts, key=instruction_counts.get, reverse=True)[:3]
|
165 |
+
print(f"Most common add-ons: {most_common_addons}")
|
166 |
+
print(f"Most common instructions: {most_common_instructions}")
|
167 |
|
168 |
return ordered_menu, referral_code, reward_points, cart_item_count, most_common_addons, most_common_instructions
|
169 |
|
|
|
307 |
FROM Cart_Item__c
|
308 |
WHERE Customer_Email__c = '{customer_email}' AND Name = '{item_name}'
|
309 |
"""
|
310 |
+
result = sf.query_all(query)
|
311 |
cart_items = result.get("records", [])
|
312 |
|
313 |
addons_price = sum(float(addon.get('price', 0)) for addon in addons)
|
|
|
369 |
return jsonify({"success": True, "message": "Item added to cart successfully.", "cart": cart})
|
370 |
|
371 |
except ValueError as e:
|
372 |
+
print(f"Invalid data format in cart add: {str(e)}")
|
373 |
return jsonify({"success": False, "error": f"Invalid data format: {str(e)}"}), 400
|
374 |
except Exception as e:
|
375 |
print(f"Error adding item to cart: {str(e)}")
|