ソースを参照

Change background job Thread process to cron-tab

Mohidul Islam 5 年 前
コミット
5dcca8538c
3 ファイル変更10 行追加4 行削除
  1. 2 3
      nlu_job/views.py
  2. 1 1
      review/background_job.py
  3. 7 0
      review_automation/settings.py

+ 2 - 3
nlu_job/views.py

@@ -3,7 +3,7 @@ from django.utils import timezone
 from django.shortcuts import redirect
 from review.forms import ReplyForm
 from review.models import Review, CustomReply
-from gauth.models import Location
+
 from difflib import SequenceMatcher
 
 from .nlu_utils import model_inference, analyze_inference
@@ -20,8 +20,7 @@ def filter_with_last_ten_reviews(location_id, replies):
             if similarity > 0.7:
                 replies.remove(rep)
                 print(similarity, '--------------', rep.reply_category)
-            # if similarity < 0.7 and rep not in reps:
-            #     reps.append(rep)
+
     return replies
 
 

+ 1 - 1
review/background_job.py

@@ -15,7 +15,7 @@ def un_replied_reviews_with_no_comment():
 
 def task():
     while True:
-        populate_reviews()
+        replies = un_replied_reviews_with_no_comment()
         # TODO: reply reviews in background
         sleep(60*60*6)
 

+ 7 - 0
review_automation/settings.py

@@ -29,6 +29,7 @@ INSTALLED_APPS = [
     'nlu_job.apps.NluJobConfig',
 
     'crispy_forms',
+    'django_crontab',
 ]
 
 MIDDLEWARE = [
@@ -124,3 +125,9 @@ CLIENT_SECRET = "ZXYpt07Su0pW3y3jPGOXY_C_"
 TOKEN_URI = "https://oauth2.googleapis.com/token"
 HOST_URI = "http://127.0.0.1:8000"
 NLU_SERVER_URI = 'http://localhost:5005'
+
+
+# Cron-Jobs of the project
+CRONJOBS = [
+    ('0 3 * * *', 'review.review_utils.populate_reviews')
+]