Browse Source

create a management command for generating word cloud

Mohidul Islam 4 years ago
parent
commit
e493ece722

+ 2 - 0
review/management/commands/collect_reviews.py

@@ -1,5 +1,6 @@
 from django.core.management.base import BaseCommand
 from review.review_utils import populate_reviews
+from facebook_app.review_utils import populate_facebook_reviews
 
 
 class Command(BaseCommand):
@@ -8,4 +9,5 @@ class Command(BaseCommand):
 
     def handle(self, *args, **options):
         populate_reviews()
+        populate_facebook_reviews()
         self.stdout.write(self.style.SUCCESS('All new reviews has been stored in the database.'))

+ 11 - 0
review/management/commands/generate_wordcloud.py

@@ -0,0 +1,11 @@
+from django.core.management.base import BaseCommand
+from manager.word_cloud import generate_word_clouds
+
+
+class Command(BaseCommand):
+
+    help = 'Generate word cloud image for all locations .'
+
+    def handle(self, *args, **options):
+        generate_word_clouds()
+        self.stdout.write(self.style.SUCCESS('Word Cloud for all locations are generated and saved into disk.'))

+ 2 - 2
review/review_utils.py

@@ -202,8 +202,8 @@ def populate_reviews():
     locations = Location.objects.all().values('location_id')
     for loc in locations:
         loc_id = loc.get('location_id')
-        sync_all_review(loc_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.')