Skip to content

Commit

Permalink
Merge pull request #72 from monkeypatch/demo/only-food
Browse files Browse the repository at this point in the history
Server will attempt to fetch reviews 3 times to avoid Yelp blacklisting
  • Loading branch information
MichaelSel authored Nov 15, 2023
2 parents 8400a2a + c400a73 commit 9ea1287
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 9ea1287

Please sign in to comment.