alert email
This commit is contained in:
@@ -756,6 +756,26 @@ def handle_updatedps(useremail, workoutids, debug=False,**kwargs):
|
|||||||
|
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
import math
|
||||||
|
def sigdig(value, digits = 3):
|
||||||
|
try:
|
||||||
|
order = int(math.floor(math.log10(math.fabs(value))))
|
||||||
|
except (ValueError,TypeError):
|
||||||
|
return value
|
||||||
|
|
||||||
|
# return integers as is
|
||||||
|
if value % 1 == 0:
|
||||||
|
return value
|
||||||
|
|
||||||
|
places = digits - order - 1
|
||||||
|
if places > 0:
|
||||||
|
fmtstr = "%%.%df" % (places)
|
||||||
|
else:
|
||||||
|
fmtstr = "%.0f"
|
||||||
|
return fmtstr % (round(value, places))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@app.task
|
@app.task
|
||||||
def handle_send_email_alert(
|
def handle_send_email_alert(
|
||||||
useremail, userfirstname, userlastname, rowerfirstname, alertname, stats, **kwargs):
|
useremail, userfirstname, userlastname, rowerfirstname, alertname, stats, **kwargs):
|
||||||
@@ -770,15 +790,26 @@ def handle_send_email_alert(
|
|||||||
else:
|
else:
|
||||||
othertexts = None
|
othertexts = None
|
||||||
|
|
||||||
subject = "Your rowing performance on rowsandall.com ({startdate} to {enddate})".format(
|
report = {}
|
||||||
|
report['Percentage'] = int(stats['percentage'])
|
||||||
|
report['Number of workouts'] = int(stats['workouts'])
|
||||||
|
report['Data set'] = "{a} strokes out of {b}".format(
|
||||||
|
a = stats['nr_strokes_qualifying'],
|
||||||
|
b = stats['nr_strokes']
|
||||||
|
)
|
||||||
|
report['Median'] = sigdig(stats['median'])
|
||||||
|
report['Median of qualifying strokes'] = sigdig(stats['median_q'])
|
||||||
|
|
||||||
|
subject = "Rowsandall.com: {alertname} ({startdate} to {enddate})".format(
|
||||||
startdate = stats['startdate'],
|
startdate = stats['startdate'],
|
||||||
enddate = stats['enddate'],
|
enddate = stats['enddate'],
|
||||||
|
alertname=alertname,
|
||||||
)
|
)
|
||||||
|
|
||||||
from_email = 'Rowsandall <info@rowsandall.com>'
|
from_email = 'Rowsandall <info@rowsandall.com>'
|
||||||
|
|
||||||
d = {
|
d = {
|
||||||
'report':stats,
|
'report':report,
|
||||||
'first_name':userfirstname,
|
'first_name':userfirstname,
|
||||||
'last_name':userlastname,
|
'last_name':userlastname,
|
||||||
'siteurl':siteurl,
|
'siteurl':siteurl,
|
||||||
|
|||||||
@@ -1,14 +1,22 @@
|
|||||||
|
<!doctype html>
|
||||||
<html>
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta name="viewport" content="width=device-width">
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||||
|
<title>Rowsandall</title>
|
||||||
|
<style>
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<font face="verdana, sans-serif">
|
<font face="verdana, sans-serif">
|
||||||
|
|
||||||
|
|
||||||
<img src="https://rowsandall.com/static/img/logoemail.png" height="50">
|
<img src="https://rowsandall.com/static/img/logoemail.png" height="50">
|
||||||
<font face="verdana, sans-serif">
|
<font face="verdana, sans-serif">
|
||||||
{% block body %}
|
{% block body %}
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
</font>
|
</font>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user