소스 검색

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


이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.