From a66730447e510ce7f22626351e00216ae0138679 Mon Sep 17 00:00:00 2001 From: Katy Huang <96160110+KatyH820@users.noreply.github.com> Date: Thu, 14 Dec 2023 19:15:04 -0800 Subject: [PATCH 1/2] change the support email on error message (#34) --- api/util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/util.py b/api/util.py index a3936d1..1f5a872 100644 --- a/api/util.py +++ b/api/util.py @@ -289,7 +289,7 @@ def get_id(location: str) -> int: { 'category': 'Error Description', 'items': [{ - 'name': 'We encountered an error getting the menu data. If the campusdish website has the menu but we don\'t, send me an email at epedley@uci.edu and I\'ll look into a fix.', + 'name': 'We encountered an error getting the menu data. If the campusdish website has the menu but we don\'t, send me an email at katyh1@uci.edu and I\'ll look into a fix.', 'description': '🤷‍♂️', "nutrition": { "isVegan": True, From caef3ace97aa649db1b1d2ad657f362eee4875d8 Mon Sep 17 00:00:00 2001 From: Katy Huang <96160110+KatyH820@users.noreply.github.com> Date: Thu, 14 Dec 2023 19:48:07 -0800 Subject: [PATCH 2/2] Api block fix (#35) --- api/campusdish_interface.py | 9 +++++++-- api/parsing.py | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/api/campusdish_interface.py b/api/campusdish_interface.py index 1b2b906..fcc266d 100644 --- a/api/campusdish_interface.py +++ b/api/campusdish_interface.py @@ -6,7 +6,6 @@ from bs4 import BeautifulSoup as bs from .util import normalize_time_from_str, parse_date, get_irvine_time, get_date_str, MEAL_TO_PERIOD, EVENTS_PLACEHOLDER, LOCATION_INFO - def get_menu_data(location, meal_id, date): ''' Given a valid location, meal_id, and date, @@ -14,8 +13,14 @@ def get_menu_data(location, meal_id, date): ''' location_id = LOCATION_INFO[location]['id'] + response = requests.get( - f'https://uci.campusdish.com/api/menu/GetMenus?locationId={location_id}&periodId={MEAL_TO_PERIOD[meal_id][0]}&date={date}' + f'https://uci.campusdish.com/api/menu/GetMenus?locationId={location_id}&periodId={MEAL_TO_PERIOD[meal_id][0]}&date={date}', + headers={'USER-AGENT': 'Mozilla/5.0', + 'accept': 'application/json, text/plain, */*', + 'accept-encoding': 'gzip, deflate, br', + 'accept-language': 'en-US,en;q=0.9', + 'cookie':'_ga=GA1.1.2135650958.1699493067; _fbp=fb.1.1699493068807.546237007; OptanonAlertBoxClosed=2023-11-18T00:27:06.194Z; OptanonConsent=isGpcEnabled=0&datestamp=Mon+Nov+27+2023+16%3A45%3A47+GMT-0800+(Pacific+Standard+Time)&version=6.23.0&isIABGlobal=false&hosts=&consentId=3f8042c6-62c9-459e-b451-8d2bb2d2bb0c&interactionCount=2&landingPath=NotLandingPage&groups=C0001%3A1%2CC0003%3A1%2CC0002%3A1%2CC0004%3A1&geolocation=US%3BCA&AwaitingReconsent=false; _ga_HKPPXV27L6=GS1.1.1701132344.7.1.1701132381.23.0.0; _ga_30LZ5B848R=GS1.1.1701132344.7.1.1701132381.23.0.0; incap_ses_2110_2829404=nmuEMn+X8GCYRr3tTzpIHdc5dWUAAAAAkCfehUkETn3bkUOXJJF9TQ==; AramarkContextInfo=32|{a906eb02-9a20-4c32-83ab-4c44aa7ecae2}|Education; visid_incap_2829404=m7L0fKSVQImqnJ+jFhGClyaxe2UAAAAAQUIPAAAAAAADAaxNzlBTEpAUu2jSBVX4; incap_ses_226_2829404=xksGaJqYfybZsHCSP+oiAyaxe2UAAAAA3Vaw3MCEMfaqz1xnNV5LOw==; __CLAnonymousUser=024VtvBU8JFjAEXI1VYrJfhiw==8E4JagTsXCI5TvhsckSrGtRhrtg8Ba2nvKbKi0oEEqer94E3xhYXibEhXRE+ld898AF9ph8JUW+dQDVwl/vOyVTizKg1NWUaH2cbV0iwhMfa35zlwhSQGRlniC+jmeXfmRIseGcC0/YDWXtDWGdeYBuDzZzLdLVEI+QiZupaYIh7WGLXyKcXB7N2n6NJ97cCMXdFegb240euayuoKELQ3dHATOy/IaiALslPWTiCEk7PEZe6efKRSkreG6QwUVw4TRsRxPbMJ+4hjSVbLq7psIo1+YIE/ZSilIrY/izKcsl2E4Gifa7DoejmUkoscdE39E1gsjdjhrmdBkhukGlMyk4FoRxGNmbnqrnejXlTbe5vLEGV6+Ux8IDe815T5qS/RwjoSJrle6gL2ixz/80RNLTx0WUNujf0DeOMV5/g8RS8eR8ePpGbOg5z1MuccNOQdaboGDa4FAkA9aR2LaIA1xgyhFPEMN2gTRwD7C5G1Vh16GMxgSyZF/aguI2FzcseaZr6FL90qvLeWY6yCg8m7VQQ0TxPSaqQufmYP8Zn53nBegruLSl6T9nXGYFxiaH14Dt2Uwzn5lC/yQAEeEzstHgS0h7+jLfP87RwaWIVjQzHdR4YryHYED++mWj7DlZ5F6lrl4dT/7SGOXfeJhXmb+NF9FAAj8pIHbo8u686DsNBGwXjJmxouuZ2dH5iwV8rAjn0cMayfkfFxRLqaqs6lG+s+MDIWX758R+2Xfjz7n0bBNhtSI1IFUU8DjxsqabUtBnXNerMq+NqYBZSTz1sdvCbBKZkFwZdlLdzvwEEt58=' } ) if response.status_code == 200: payload = response.json() diff --git a/api/parsing.py b/api/parsing.py index 8b9baef..49c46a1 100644 --- a/api/parsing.py +++ b/api/parsing.py @@ -30,7 +30,6 @@ def _find_icon(icon_property: str, food_info: dict) -> bool: station_id_to_name = dict( [(entry['StationId'], entry['Name']) for entry in menu_data["MenuStations"]]) - dish_list = menu_data["MenuProducts"] for dish in dish_list: @@ -83,8 +82,9 @@ def make_response_body(location: str, meal_id: int = None, date: str = None) -> restaurant = get_name(location) schedule = get_schedule_data(restaurant) + date = date or get_irvine_date() return { - 'date': date or get_irvine_date(), + 'date': date, 'restaurant': restaurant, 'refreshTime': int(time.time()), 'schedule': schedule,