through email now
This commit is contained in:
@@ -135,15 +135,6 @@ def rdata(file,rower=rrower()):
|
|||||||
|
|
||||||
from utils import totaltime_sec_to_string
|
from utils import totaltime_sec_to_string
|
||||||
|
|
||||||
def create_strava_stroke_data_db(workoutid,df,csvfilename,debug=False):
|
|
||||||
df.sort_values(by='TimeStamp (sec)',ascending=True)
|
|
||||||
|
|
||||||
res = df.to_csv(csvfilename+'.gz',index_label='index',compression='gzip')
|
|
||||||
|
|
||||||
row = rrdata(csvfile=csvfilename+'.gz')
|
|
||||||
data = dataprep(row.df,id=workoutid,bands=False,debug=debug)
|
|
||||||
|
|
||||||
return data
|
|
||||||
|
|
||||||
# Creates C2 stroke data
|
# Creates C2 stroke data
|
||||||
def create_c2_stroke_data_db(
|
def create_c2_stroke_data_db(
|
||||||
|
|||||||
@@ -165,7 +165,7 @@ def get_strava_workouts(rower):
|
|||||||
newids = [stravaid for stravaid in stravaids if not stravaid in knownstravaids]
|
newids = [stravaid for stravaid in stravaids if not stravaid in knownstravaids]
|
||||||
|
|
||||||
for stravaid in newids:
|
for stravaid in newids:
|
||||||
workoutid = create_async_workout(alldata,rower.user,stravaid)
|
result = create_async_workout(alldata,rower.user,stravaid)
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
@@ -234,29 +234,38 @@ def create_async_workout(alldata,user,stravaid,debug=False):
|
|||||||
code = uuid4().hex[:16]
|
code = uuid4().hex[:16]
|
||||||
)
|
)
|
||||||
|
|
||||||
w = Workout(
|
# w = Workout(
|
||||||
user=r,
|
# user=r,
|
||||||
workouttype = workouttype,
|
# workouttype = workouttype,
|
||||||
name = title,
|
# name = title,
|
||||||
date = workoutdate,
|
# date = workoutdate,
|
||||||
starttime = starttime,
|
# starttime = starttime,
|
||||||
startdatetime = rowdatetime,
|
# startdatetime = rowdatetime,
|
||||||
timezone = thetimezone,
|
# timezone = thetimezone,
|
||||||
duration = duration,
|
# duration = duration,
|
||||||
distance=distance,
|
# distance=distance,
|
||||||
weightcategory = weightcategory,
|
# weightcategory = weightcategory,
|
||||||
uploadedtostrava = stravaid,
|
# uploadedtostrava = stravaid,
|
||||||
csvfilename = csvfilename,
|
# csvfilename = csvfilename,
|
||||||
notes = ''
|
# notes = ''
|
||||||
)
|
# )
|
||||||
|
|
||||||
w.save()
|
|
||||||
|
|
||||||
# Check if workout has stroke data, and get the stroke data
|
# Check if workout has stroke data, and get the stroke data
|
||||||
|
|
||||||
result = add_stroke_data(user,stravaid,w.id,rowdatetime,csvfilename,debug=debug)
|
starttimeunix = arrow.get(rowdatetime).timestamp
|
||||||
|
|
||||||
return w.id
|
job = myqueue(queue,
|
||||||
|
handle_strava_import_stroke_data,
|
||||||
|
title,
|
||||||
|
user.email,
|
||||||
|
r.stravatoken,
|
||||||
|
stravaid,
|
||||||
|
starttimeunix,
|
||||||
|
csvfilename,
|
||||||
|
)
|
||||||
|
|
||||||
|
return 1
|
||||||
|
|
||||||
from utils import get_strava_stream
|
from utils import get_strava_stream
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ from rowsandall_app.settings import SITE_URL
|
|||||||
from rowsandall_app.settings_dev import SITE_URL as SITE_URL_DEV
|
from rowsandall_app.settings_dev import SITE_URL as SITE_URL_DEV
|
||||||
from rowsandall_app.settings import PROGRESS_CACHE_SECRET
|
from rowsandall_app.settings import PROGRESS_CACHE_SECRET
|
||||||
from rowsandall_app.settings import SETTINGS_NAME
|
from rowsandall_app.settings import SETTINGS_NAME
|
||||||
|
from rowsandall_app.settings import workoutemailbox
|
||||||
|
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@ from rowers.dataprepnodjango import (
|
|||||||
add_c2_stroke_data_db,totaltime_sec_to_string,
|
add_c2_stroke_data_db,totaltime_sec_to_string,
|
||||||
create_c2_stroke_data_db,update_empower,
|
create_c2_stroke_data_db,update_empower,
|
||||||
database_url_debug,database_url,dataprep,
|
database_url_debug,database_url,dataprep,
|
||||||
create_strava_stroke_data_db
|
# create_strava_stroke_data_db
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -83,8 +83,10 @@ def add(x, y):
|
|||||||
|
|
||||||
|
|
||||||
@app.task
|
@app.task
|
||||||
def handle_strava_import_stroke_data(stravatoken,
|
def handle_strava_import_stroke_data(title,
|
||||||
stravaid,workoutid,
|
useremail,
|
||||||
|
stravatoken,
|
||||||
|
stravaid,
|
||||||
starttimeunix,
|
starttimeunix,
|
||||||
csvfilename,debug=True,**kwargs):
|
csvfilename,debug=True,**kwargs):
|
||||||
# ready to fetch. Hurray
|
# ready to fetch. Hurray
|
||||||
@@ -202,8 +204,21 @@ def handle_strava_import_stroke_data(stravatoken,
|
|||||||
' Power (watts)':watts,
|
' Power (watts)':watts,
|
||||||
})
|
})
|
||||||
|
|
||||||
res = create_strava_stroke_data_db(workoutid,df,csvfilename,debug=debug)
|
|
||||||
|
|
||||||
|
df.sort_values(by='TimeStamp (sec)',ascending=True)
|
||||||
|
|
||||||
|
res = df.to_csv(csvfilename+'.gz',index_label='index',compression='gzip')
|
||||||
|
|
||||||
|
d = {
|
||||||
|
'some_attribute':1
|
||||||
|
}
|
||||||
|
|
||||||
|
res = send_template_email(useremail,[workoutemailbox],
|
||||||
|
title,'workoutemail.html',
|
||||||
|
d,
|
||||||
|
attach_file=csvfilename+'.gz')
|
||||||
|
|
||||||
|
os.remove(csvfilename+'.gz')
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
|||||||
7
rowers/templates/workoutemail.html
Normal file
7
rowers/templates/workoutemail.html
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
{% extends "emailbase.html" %}
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
@@ -10263,10 +10263,7 @@ def workout_getstravaworkout_next(request):
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
url = reverse(r.defaultlandingpage,
|
url = reverse(workouts_view)
|
||||||
kwargs={
|
|
||||||
'id':workoutid,
|
|
||||||
})
|
|
||||||
return HttpResponseRedirect(url)
|
return HttpResponseRedirect(url)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -409,3 +409,9 @@ except KeyError:
|
|||||||
WARNING_MESSAGE = ''
|
WARNING_MESSAGE = ''
|
||||||
|
|
||||||
SETTINGS_NAME = 'rowsandall_app.settings'
|
SETTINGS_NAME = 'rowsandall_app.settings'
|
||||||
|
|
||||||
|
# Workout email box
|
||||||
|
try:
|
||||||
|
workoutemailbox = CFG['workoutemailbox']
|
||||||
|
except KeyError:
|
||||||
|
workoutemailbox = 'workouts@rowsandall.com'
|
||||||
|
|||||||
Reference in New Issue
Block a user