|
@@ -108,8 +108,8 @@ def sync_all_review(loc_id):
|
|
|
headers = get_auth_header()
|
|
|
continue
|
|
|
data = res.json()
|
|
|
- reviews = data['reviews']
|
|
|
- if len(reviews) != 0:
|
|
|
+ reviews = data.get('reviews')
|
|
|
+ if reviews:
|
|
|
insert_review_into_database(reviews, loc_id)
|
|
|
next_page_token = data.get('nextPageToken')
|
|
|
if next_page_token is None:
|
|
@@ -202,7 +202,8 @@ def populate_reviews():
|
|
|
locations = Location.objects.all().values('location_id')
|
|
|
for loc in locations:
|
|
|
loc_id = loc.get('location_id')
|
|
|
- fetch_last_20_reviews(loc_id, page_size=200)
|
|
|
+ sync_all_review(loc_id)
|
|
|
+ # fetch_last_20_reviews(loc_id, page_size=200)
|
|
|
end = timezone.now()
|
|
|
elapsed = end - start
|
|
|
print(f'Elapsed time: {elapsed.seconds//60} minutes and {elapsed.seconds % 60} secs.')
|