nagasurendra commited on
Commit
bc8319c
·
verified ·
1 Parent(s): 23506ad

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -5
app.py CHANGED
@@ -407,17 +407,24 @@ def menu():
407
  item['Total_Ordered__c'] = 0 # Default value
408
 
409
  # Sort items by Total_Ordered__c in descending order and pick top 4 as best sellers
410
- best_sellers = sorted(food_items, key=lambda x: x.get("Total_Ordered__c", 0), reverse=True)[:4]
411
  print(f"Best sellers: {[item['Name'] for item in best_sellers]}") # Debugging
 
 
 
 
412
 
413
- # Define the order of sections, adding "Best Sellers" at the top
414
- section_order = ["Best Sellers", "Starters","Biryanis","Curries","Breads","Apetizer", "Desserts", "Soft Drinks"]
415
- ordered_menu = {section: [] for section in section_order}
416
 
417
- # Add best sellers to ordered_menu if there are any
418
  if best_sellers:
419
  ordered_menu["Best Sellers"] = best_sellers
420
 
 
 
 
 
421
  # Filter and organize menu items based on category and section
422
  for item in food_items:
423
  section = item.get("Section__c", "Others") # Default to "Others" if missing
 
407
  item['Total_Ordered__c'] = 0 # Default value
408
 
409
  # Sort items by Total_Ordered__c in descending order and pick top 4 as best sellers
410
+ best_sellers = sorted(food_items, key=lambda x: x.get("Total_Ordered__c", 0), reverse=True)
411
  print(f"Best sellers: {[item['Name'] for item in best_sellers]}") # Debugging
412
+ if selected_category == "Veg":
413
+ best_sellers = [item for item in best_sellers if item.get("Veg_NonVeg__c") in ["Veg", "both"]]
414
+ elif selected_category == "Non veg":
415
+ best_sellers = [item for item in best_sellers if item.get("Veg_NonVeg__c") in ["Non veg", "both"]]
416
 
417
+ # Take only the top 4 best sellers after filtering
418
+ best_sellers = best_sellers[:4]
 
419
 
420
+ # Ensure "Best Sellers" is added only if there are items after filtering
421
  if best_sellers:
422
  ordered_menu["Best Sellers"] = best_sellers
423
 
424
+ # Define the order of sections, adding "Best Sellers" at the top
425
+ section_order = ["Best Sellers", "Starters","Biryanis","Curries","Breads","Apetizer", "Desserts", "Soft Drinks"]
426
+ ordered_menu = {section: [] for section in section_order}
427
+
428
  # Filter and organize menu items based on category and section
429
  for item in food_items:
430
  section = item.get("Section__c", "Others") # Default to "Others" if missing