Sfoglia il codice sorgente

Added a function that generate reply for no_commented review

Mohidul Islam 5 anni fa
parent
commit
d9dac6f4c1
1 ha cambiato i file con 16 aggiunte e 3 eliminazioni
  1. 16 3
      review/background_job.py

+ 16 - 3
review/background_job.py

@@ -1,9 +1,9 @@
 from threading import Thread
 from time import sleep
 from django.utils import timezone
-
+from random import choice
 from .models import Review, CustomReply
-from .review_utils import populate_reviews
+from nlu_job.nlu_utils import is_a_name
 
 
 def un_replied_reviews_with_no_comment():
@@ -13,9 +13,22 @@ def un_replied_reviews_with_no_comment():
     return reviews
 
 
+def generate_reply(review):
+    replies = CustomReply.objects.filter(reply_category='no_comment')
+    reply = choice(replies)
+    name = review.reviewer_name
+    if is_a_name(name):
+        parsable_name = ', '+name.title()
+    else:
+        parsable_name = ''
+    replied_text = reply.reply %parsable_name
+    return replied_text
+
+
+
 def task():
     while True:
-        replies = un_replied_reviews_with_no_comment()
+        reviews = un_replied_reviews_with_no_comment()
         # TODO: reply reviews in background
         sleep(60*60*6)