Browse Source

update database

pabon 4 years ago
parent
commit
82a41e1925
2 changed files with 7 additions and 6 deletions
  1. 4 3
      review/review_utils.py
  2. 3 3
      review_automation.sql

+ 4 - 3
review/review_utils.py

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

File diff suppressed because it is too large
+ 3 - 3
review_automation.sql


Some files were not shown because too many files changed in this diff