Skip to content

Commit

Permalink
Api block fix (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
KatyH820 authored Dec 15, 2023
1 parent a667304 commit caef3ac
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 7 additions & 2 deletions api/campusdish_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,21 @@
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,
perform get request for the diner_json and return the dict at diner_json['Menu']
'''
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()
Expand Down
4 changes: 2 additions & 2 deletions api/parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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,
Expand Down

1 comment on commit caef3ac

@vercel
Copy link

@vercel vercel bot commented on caef3ac Dec 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.