|
@@ -1,12 +1,11 @@
|
|
|
import random
|
|
|
from time import sleep
|
|
|
from django.utils import timezone
|
|
|
-from gauth.models import Location
|
|
|
from .models import Review, CustomReply, Reply
|
|
|
from nlu_job.nlu_utils import is_a_name
|
|
|
from review.review_utils import reply_review
|
|
|
from review.review_utils import populate_reviews, get_bad_reviews
|
|
|
-from analytics.send_email import send_email
|
|
|
+from analytics.background_job import send_email_bad_reviews
|
|
|
|
|
|
from nameparser import HumanName
|
|
|
|
|
@@ -58,19 +57,8 @@ def reply_uncommented_reviews():
|
|
|
sleep(60*random.randint(2, 5))
|
|
|
|
|
|
|
|
|
-def send_email_bad_reviews():
|
|
|
- locations = Location.objects.all()
|
|
|
- for location in locations:
|
|
|
- reviews = get_bad_reviews(location.location_id, hours=6)
|
|
|
- total_reviews = reviews.count()
|
|
|
- if total_reviews > 0:
|
|
|
- to = [location.recipient_email if location.recipient_email else 'bt@bytetrek.com.bd']
|
|
|
- subject = "A bad review has been post."
|
|
|
- message = f"hi there is {total_reviews} bad review in {location.care_name} please response to reviewer ASAP"
|
|
|
- send_email(to_list=to, subject=subject, message=message)
|
|
|
-
|
|
|
-
|
|
|
def background_task():
|
|
|
populate_reviews()
|
|
|
+ send_email_bad_reviews()
|
|
|
sleep(60 * random.randint(2, 5))
|
|
|
reply_uncommented_reviews()
|