ソースを参照

update database

pabon 4 年 前
コミット
82a41e1925
2 ファイル変更7 行追加6 行削除
  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()
             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.')

ファイルの差分が大きいため隠しています
+ 3 - 3
review_automation.sql


この差分においてかなりの量のファイルが変更されているため、一部のファイルを表示していません