|
@@ -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)
|
|
|
|