Private
Public Access
1
0

through email now

This commit is contained in:
Sander Roosendaal
2018-06-28 14:26:08 +02:00
parent f3edead9b9
commit 6acb5d9f49
6 changed files with 62 additions and 37 deletions

View File

@@ -135,15 +135,6 @@ def rdata(file,rower=rrower()):
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
def create_c2_stroke_data_db(

View File

@@ -165,7 +165,7 @@ def get_strava_workouts(rower):
newids = [stravaid for stravaid in stravaids if not stravaid in knownstravaids]
for stravaid in newids:
workoutid = create_async_workout(alldata,rower.user,stravaid)
result = create_async_workout(alldata,rower.user,stravaid)
return 1
@@ -234,29 +234,38 @@ def create_async_workout(alldata,user,stravaid,debug=False):
code = uuid4().hex[:16]
)
w = Workout(
user=r,
workouttype = workouttype,
name = title,
date = workoutdate,
starttime = starttime,
startdatetime = rowdatetime,
timezone = thetimezone,
duration = duration,
distance=distance,
weightcategory = weightcategory,
uploadedtostrava = stravaid,
csvfilename = csvfilename,
notes = ''
)
# w = Workout(
# user=r,
# workouttype = workouttype,
# name = title,
# date = workoutdate,
# starttime = starttime,
# startdatetime = rowdatetime,
# timezone = thetimezone,
# duration = duration,
# distance=distance,
# weightcategory = weightcategory,
# uploadedtostrava = stravaid,
# csvfilename = csvfilename,
# notes = ''
# )
w.save()
# 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

View File

@@ -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 import PROGRESS_CACHE_SECRET
from rowsandall_app.settings import SETTINGS_NAME
from rowsandall_app.settings import workoutemailbox
import pandas as pd
@@ -48,7 +48,7 @@ from rowers.dataprepnodjango import (
add_c2_stroke_data_db,totaltime_sec_to_string,
create_c2_stroke_data_db,update_empower,
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
def handle_strava_import_stroke_data(stravatoken,
stravaid,workoutid,
def handle_strava_import_stroke_data(title,
useremail,
stravatoken,
stravaid,
starttimeunix,
csvfilename,debug=True,**kwargs):
# ready to fetch. Hurray
@@ -202,8 +204,21 @@ def handle_strava_import_stroke_data(stravatoken,
' 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

View File

@@ -0,0 +1,7 @@
{% extends "emailbase.html" %}
{% block body %}
{% endblock %}

View File

@@ -10263,10 +10263,7 @@ def workout_getstravaworkout_next(request):
url = reverse(r.defaultlandingpage,
kwargs={
'id':workoutid,
})
url = reverse(workouts_view)
return HttpResponseRedirect(url)