Skip to content

Commit

Permalink
Server will attempt to fetch reviews 3 times to avoid Yelp blacklisting
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelSel committed Nov 15, 2023
1 parent de2ab39 commit c400a73
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions apps/routers/food_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@

@router.get("")
async def analyze_reviews(url: str):
max_attempts = 3
print("Got ALIAS:", url)
print("Fetching reviews")
reviews = get_yelp_reviews(url)
print("Got reviews")

max_reviews = 20
if len(reviews) == 0:
return {
"message": "error",
}
while len(reviews) == 0 and max_attempts > 0:
reviews = get_yelp_reviews(url)
max_attempts -= 1
print("Here is the first review:")
print(reviews[0])
if len(reviews) > max_reviews:
Expand Down

0 comments on commit c400a73

Please sign in to comment.