adding logging in dataprep - for datetime issues
This commit is contained in:
@@ -92,7 +92,7 @@ import sqlalchemy as sa
|
|||||||
import sys
|
import sys
|
||||||
import rowers.utils as utils
|
import rowers.utils as utils
|
||||||
import rowers.datautils as datautils
|
import rowers.datautils as datautils
|
||||||
from rowers.utils import lbstoN,myqueue,wavg
|
from rowers.utils import lbstoN,myqueue,wavg,dologging
|
||||||
|
|
||||||
from timezonefinder import TimezoneFinder
|
from timezonefinder import TimezoneFinder
|
||||||
|
|
||||||
@@ -1603,6 +1603,10 @@ def save_workout_database(f2, r, dosmooth=True, workouttype='rower',
|
|||||||
if startdatetime != '': # pragma: no cover
|
if startdatetime != '': # pragma: no cover
|
||||||
row.rowdatetime = arrow.get(startdatetime).datetime
|
row.rowdatetime = arrow.get(startdatetime).datetime
|
||||||
|
|
||||||
|
dologging('debuglog.log','Row Date Time (line 1606) = {rowdatetime}'.format(
|
||||||
|
rowdatetime=row.rowdatetime,
|
||||||
|
))
|
||||||
|
|
||||||
|
|
||||||
if title is None or title == '':
|
if title is None or title == '':
|
||||||
title = 'Workout'
|
title = 'Workout'
|
||||||
@@ -1730,6 +1734,11 @@ def save_workout_database(f2, r, dosmooth=True, workouttype='rower',
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
dologging('debuglog.log','Dataprep line 1737, Workout Startdatetime {workoutstartdatetime}'.format(
|
||||||
|
workoutstartdatetime=workoutstartdatetime,
|
||||||
|
))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1768,6 +1777,11 @@ def save_workout_database(f2, r, dosmooth=True, workouttype='rower',
|
|||||||
pytz.timezone(timezone_str)
|
pytz.timezone(timezone_str)
|
||||||
).strftime('%H:%M:%S')
|
).strftime('%H:%M:%S')
|
||||||
|
|
||||||
|
s = 'Dataprep line 1780 workoutdate and time set to {workoutdate} and {workoutstarttime}'.format(
|
||||||
|
workoutdate=workoutdate,
|
||||||
|
workoutstarttime=workoutstarttime,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
if makeprivate: # pragma: no cover
|
if makeprivate: # pragma: no cover
|
||||||
privacy = 'hidden'
|
privacy = 'hidden'
|
||||||
@@ -1889,6 +1903,12 @@ def parsenonpainsled(fileformat,f2,summary,startdatetime='',empowerfirmware=None
|
|||||||
hasrecognized = False
|
hasrecognized = False
|
||||||
return None, hasrecognized, '', 'unknown'
|
return None, hasrecognized, '', 'unknown'
|
||||||
|
|
||||||
|
s = 'Parsenonpainsled, start date time = {startdatetime}'.format(
|
||||||
|
startdatetime = startdatetime,
|
||||||
|
#rowdatetime = row.rowdatetime
|
||||||
|
)
|
||||||
|
dologging('debuglog.log',s)
|
||||||
|
|
||||||
# handle speed coach GPS 2
|
# handle speed coach GPS 2
|
||||||
if (fileformat == 'speedcoach2'):
|
if (fileformat == 'speedcoach2'):
|
||||||
oarlength, inboard = get_empower_rigging(f2)
|
oarlength, inboard = get_empower_rigging(f2)
|
||||||
@@ -2159,6 +2179,10 @@ def new_workout_from_file(r, f2,
|
|||||||
if workoutsource is None:
|
if workoutsource is None:
|
||||||
workoutsource = fileformat
|
workoutsource = fileformat
|
||||||
|
|
||||||
|
dologging('debuglog.log','Saving to database with start date time {startdatetime}'.format(
|
||||||
|
startdatetime=startdatetime,
|
||||||
|
))
|
||||||
|
|
||||||
id, message = save_workout_database(
|
id, message = save_workout_database(
|
||||||
f2, r,
|
f2, r,
|
||||||
notes=notes,
|
notes=notes,
|
||||||
|
|||||||
@@ -3167,6 +3167,8 @@ def handle_c2_async_workout(alldata,userid,c2token,c2id,delaysec,defaulttimezone
|
|||||||
dologging('debuglog.log',s.text)
|
dologging('debuglog.log',s.text)
|
||||||
has_strokedata = False
|
has_strokedata = False
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if not has_strokedata: # pragma: no cover
|
if not has_strokedata: # pragma: no cover
|
||||||
df = df_from_summary(data)
|
df = df_from_summary(data)
|
||||||
else:
|
else:
|
||||||
@@ -3220,6 +3222,7 @@ def handle_c2_async_workout(alldata,userid,c2token,c2id,delaysec,defaulttimezone
|
|||||||
velo = 1000./pace
|
velo = 1000./pace
|
||||||
|
|
||||||
dologging('debuglog.log','Unix Time Stamp {s}'.format(s=unixtime[0]))
|
dologging('debuglog.log','Unix Time Stamp {s}'.format(s=unixtime[0]))
|
||||||
|
#dologging('debuglog.log',json.dumps(s.json()))
|
||||||
|
|
||||||
df = pd.DataFrame({'TimeStamp (sec)':unixtime,
|
df = pd.DataFrame({'TimeStamp (sec)':unixtime,
|
||||||
' Horizontal (meters)': dist2,
|
' Horizontal (meters)': dist2,
|
||||||
|
|||||||
@@ -394,6 +394,55 @@ class C2Objects(DjangoTestCase):
|
|||||||
self.assertEqual(got, want)
|
self.assertEqual(got, want)
|
||||||
self.assertEqual(workoutdate,'2021-06-06')
|
self.assertEqual(workoutdate,'2021-06-06')
|
||||||
|
|
||||||
|
def test_c2_import_54744009(self):
|
||||||
|
with open('rowers/tests/testdata/c2_54744009.json','r') as infile:
|
||||||
|
data = json.load(infile)
|
||||||
|
(
|
||||||
|
startdatetime,
|
||||||
|
starttime,
|
||||||
|
workoutdate,
|
||||||
|
duration,
|
||||||
|
starttimeunix,
|
||||||
|
timezone
|
||||||
|
) = utils.get_startdatetime_from_c2data(data)
|
||||||
|
|
||||||
|
|
||||||
|
self.assertEqual(str(timezone),'America/Los_Angeles')
|
||||||
|
|
||||||
|
got = arrow.get(startdatetime).isoformat()
|
||||||
|
want = arrow.get('2021-06-02 08:07:04.7-07:00').isoformat()
|
||||||
|
|
||||||
|
self.assertEqual(got, want)
|
||||||
|
self.assertEqual(workoutdate,'2021-06-02')
|
||||||
|
|
||||||
|
def test_c2_import_54933639(self):
|
||||||
|
with open('rowers/tests/testdata/c2_54933639.json','r') as infile:
|
||||||
|
data = json.load(infile)
|
||||||
|
(
|
||||||
|
startdatetime,
|
||||||
|
starttime,
|
||||||
|
workoutdate,
|
||||||
|
duration,
|
||||||
|
starttimeunix,
|
||||||
|
timezone
|
||||||
|
) = utils.get_startdatetime_from_c2data(data)
|
||||||
|
|
||||||
|
|
||||||
|
self.assertEqual(str(timezone),'America/Los_Angeles')
|
||||||
|
|
||||||
|
got = arrow.get(startdatetime).isoformat()
|
||||||
|
want = arrow.get('2021-06-10 19:22:02.600000-07:00').isoformat()
|
||||||
|
|
||||||
|
self.assertEqual(got, want)
|
||||||
|
self.assertEqual(workoutdate,'2021-06-10')
|
||||||
|
|
||||||
|
want = arrow.get('2021-06-10 19:22:02.600000-07:00').timestamp()
|
||||||
|
got = 1623378122.6
|
||||||
|
self.assertEqual(got, want)
|
||||||
|
|
||||||
|
got = arrow.get(startdatetime).timestamp()
|
||||||
|
self.assertEqual(got, want)
|
||||||
|
|
||||||
|
|
||||||
@patch('rowers.c2stuff.requests.get', side_effect=mocked_requests)
|
@patch('rowers.c2stuff.requests.get', side_effect=mocked_requests)
|
||||||
@patch('rowers.dataprep.create_engine')
|
@patch('rowers.dataprep.create_engine')
|
||||||
|
|||||||
@@ -4817,6 +4817,14 @@ def workout_upload_api(request):
|
|||||||
summary = post_data.get('summary',None)
|
summary = post_data.get('summary',None)
|
||||||
timezone = post_data.get('timezone',None)
|
timezone = post_data.get('timezone',None)
|
||||||
|
|
||||||
|
s = 'Posting c2id {c2id} to Rowsandall. Startdatetime {startdatetime}, time zone {timezone}'.format(
|
||||||
|
c2id=c2id,
|
||||||
|
startdatetime=startdatetime,
|
||||||
|
timezone=timezone,
|
||||||
|
)
|
||||||
|
|
||||||
|
dologging('debuglog.log',s)
|
||||||
|
|
||||||
r = None
|
r = None
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
t = form.cleaned_data['title']
|
t = form.cleaned_data['title']
|
||||||
|
|||||||
Reference in New Issue
Block a user