|
@@ -2,16 +2,24 @@ import requests
|
|
from django.conf import settings
|
|
from django.conf import settings
|
|
from gauth.models import Location
|
|
from gauth.models import Location
|
|
from analytics.send_email import send_email
|
|
from analytics.send_email import send_email
|
|
|
|
+from yelp.store_reviews import populate_reviews
|
|
|
|
+
|
|
|
|
+to = getattr(settings, 'ADMIN_MAINTEINER_EMAILS')
|
|
|
|
+host_url = getattr(settings, 'HOST_URI')
|
|
|
|
|
|
|
|
|
|
def send_email_weekly_summary():
|
|
def send_email_weekly_summary():
|
|
# locations = Location.objects.all()
|
|
# locations = Location.objects.all()
|
|
- locations = Location.objects.filter(location_id='3511292162159714121')
|
|
|
|
|
|
+ locations = Location.objects.filter(location_id='14748677429039074158')
|
|
for location in locations:
|
|
for location in locations:
|
|
- to = getattr(settings, 'ADMIN_MAINTEINER_EMAILS')
|
|
|
|
to.append(location.recipient_email) if location.recipient_email else None
|
|
to.append(location.recipient_email) if location.recipient_email else None
|
|
subject = f"Weekly report for {location.care_name}."
|
|
subject = f"Weekly report for {location.care_name}."
|
|
- url = f'http://127.0.0.1:8000/analytics/weekly-report/{location.location_id}'
|
|
|
|
|
|
+ url = f'{host_url}/analytics/weekly-report/{location.location_id}'
|
|
message_body = requests.get(url).text
|
|
message_body = requests.get(url).text
|
|
message_body += '<br><p>Regards,</p><p>Byte Trek Team</p>'
|
|
message_body += '<br><p>Regards,</p><p>Byte Trek Team</p>'
|
|
- send_email(to_list=to, subject=subject, message=message_body)
|
|
|
|
|
|
+ send_email(to_list=to, subject=subject, message=message_body)
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+def background_task_7_days_interval():
|
|
|
|
+ populate_reviews()
|
|
|
|
+ send_email_weekly_summary()
|