diff --git a/rowers/dataprepnodjango.py b/rowers/dataprepnodjango.py index d2f3c84a..6ddc3a88 100644 --- a/rowers/dataprepnodjango.py +++ b/rowers/dataprepnodjango.py @@ -220,36 +220,36 @@ def add_c2_stroke_data_db(strokedata,workoutid,starttimeunix,csvfilename, unixtime = cum_time+starttimeunix # unixtime[0] = starttimeunix - seconds = 0.1*strokedata.ix[:,'t'] + seconds = 0.1*strokedata.loc[:,'t'] nr_rows = len(unixtime) try: - latcoord = strokedata.ix[:,'lat'] - loncoord = strokedata.ix[:,'lon'] + latcoord = strokedata.loc[:,'lat'] + loncoord = strokedata.loc[:,'lon'] except: latcoord = np.zeros(nr_rows) loncoord = np.zeros(nr_rows) try: - strokelength = strokedata.ix[:,'strokelength'] + strokelength = strokedata.loc[:,'strokelength'] except: strokelength = np.zeros(nr_rows) - dist2 = 0.1*strokedata.ix[:,'d'] + dist2 = 0.1*strokedata.loc[:,'d'] try: - spm = strokedata.ix[:,'spm'] + spm = strokedata.loc[:,'spm'] except KeyError: spm = 0*dist2 try: - hr = strokedata.ix[:,'hr'] + hr = strokedata.loc[:,'hr'] except KeyError: hr = 0*spm - pace = strokedata.ix[:,'p']/10. + pace = strokedata.loc[:,'p']/10. pace = np.clip(pace,0,1e4) pace = pace.replace(0,300) @@ -385,7 +385,7 @@ def save_workout_database(f2,r,dosmooth=True,workouttype='rower', totaldist = row.df['cum_dist'].max() if totaltime == 0: totaltime = row.df['TimeStamp (sec)'].max()-row.df['TimeStamp (sec)'].min() - totaltime = totaltime+row.df.ix[0,' ElapsedTime (sec)'] + totaltime = totaltime+row.df.loc[0,' ElapsedTime (sec)'] @@ -968,38 +968,38 @@ def dataprep(rowdatadf,id=0,bands=True,barchart=True,otwpower=True, print("dataprep",id) # rowdatadf.set_index([range(len(rowdatadf))],inplace=True) - t = rowdatadf.ix[:,'TimeStamp (sec)'] - t = pd.Series(t-rowdatadf.ix[0,'TimeStamp (sec)']) + t = rowdatadf.loc[:,'TimeStamp (sec)'] + t = pd.Series(t-rowdatadf.loc[:,'TimeStamp (sec)'].iloc[0]) - row_index = rowdatadf.ix[:,' Stroke500mPace (sec/500m)'] > 3000 + row_index = rowdatadf.loc[:,' Stroke500mPace (sec/500m)'] > 3000 rowdatadf.loc[row_index,' Stroke500mPace (sec/500m)'] = 3000. - p = rowdatadf.ix[:,' Stroke500mPace (sec/500m)'] + p = rowdatadf.loc[:,' Stroke500mPace (sec/500m)'] try: - velo = rowdatadf.ix[:,' AverageBoatSpeed (m/s)'] + velo = rowdatadf.loc[:,' AverageBoatSpeed (m/s)'] except KeyError: velo = 500./p - hr = rowdatadf.ix[:,' HRCur (bpm)'] - spm = rowdatadf.ix[:,' Cadence (stokes/min)'] - cumdist = rowdatadf.ix[:,'cum_dist'] + hr = rowdatadf.loc[:,' HRCur (bpm)'] + spm = rowdatadf.loc[:,' Cadence (stokes/min)'] + cumdist = rowdatadf.loc[:,'cum_dist'] - power = rowdatadf.ix[:,' Power (watts)'] - averageforce = rowdatadf.ix[:,' AverageDriveForce (lbs)'] - drivelength = rowdatadf.ix[:,' DriveLength (meters)'] + power = rowdatadf.loc[:,' Power (watts)'] + averageforce = rowdatadf.loc[:,' AverageDriveForce (lbs)'] + drivelength = rowdatadf.loc[:,' DriveLength (meters)'] try: - workoutstate = rowdatadf.ix[:,' WorkoutState'] + workoutstate = rowdatadf.loc[:,' WorkoutState'] except KeyError: workoutstate = 0*hr - peakforce = rowdatadf.ix[:,' PeakDriveForce (lbs)'] + peakforce = rowdatadf.loc[:,' PeakDriveForce (lbs)'] forceratio = averageforce/peakforce forceratio = forceratio.fillna(value=0) try: - drivetime = rowdatadf.ix[:,' DriveTime (ms)'] - recoverytime = rowdatadf.ix[:,' StrokeRecoveryTime (ms)'] + drivetime = rowdatadf.loc[:,' DriveTime (ms)'] + recoverytime = rowdatadf.loc[:,' StrokeRecoveryTime (ms)'] rhythm = 100.*drivetime/(recoverytime+drivetime) rhythm = rhythm.fillna(value=0) except: @@ -1047,7 +1047,7 @@ def dataprep(rowdatadf,id=0,bands=True,barchart=True,otwpower=True, else: drivenergy = drivelength*averageforce - distance = rowdatadf.ix[:,'cum_dist'] + distance = rowdatadf.loc[:,'cum_dist'] velo = 500./p @@ -1081,23 +1081,23 @@ def dataprep(rowdatadf,id=0,bands=True,barchart=True,otwpower=True, if bands: # HR bands - data['hr_ut2'] = rowdatadf.ix[:,'hr_ut2'] - data['hr_ut1'] = rowdatadf.ix[:,'hr_ut1'] - data['hr_at'] = rowdatadf.ix[:,'hr_at'] - data['hr_tr'] = rowdatadf.ix[:,'hr_tr'] - data['hr_an'] = rowdatadf.ix[:,'hr_an'] - data['hr_max'] = rowdatadf.ix[:,'hr_max'] + data['hr_ut2'] = rowdatadf.loc[:,'hr_ut2'] + data['hr_ut1'] = rowdatadf.loc[:,'hr_ut1'] + data['hr_at'] = rowdatadf.loc[:,'hr_at'] + data['hr_tr'] = rowdatadf.loc[:,'hr_tr'] + data['hr_an'] = rowdatadf.loc[:,'hr_an'] + data['hr_max'] = rowdatadf.loc[:,'hr_max'] data['hr_bottom'] = 0.0*data['hr'] try: - tel = rowdatadf.ix[:,' ElapsedTime (sec)'] + tel = rowdatadf.loc[:,' ElapsedTime (sec)'] except KeyError: rowdatadf[' ElapsedTime (sec)'] = rowdatadf['TimeStamp (sec)'] if barchart: # time increments for bar chart - time_increments = rowdatadf.ix[:,' ElapsedTime (sec)'].diff() + time_increments = rowdatadf.loc[:,' ElapsedTime (sec)'].diff() time_increments[0] = time_increments[1] time_increments = 0.5*time_increments+0.5*np.abs(time_increments) x_right = (t2+time_increments.apply(lambda x:timedeltaconv(x))) @@ -1106,29 +1106,29 @@ def dataprep(rowdatadf,id=0,bands=True,barchart=True,otwpower=True, if empower: try: - wash = rowdatadf.ix[:,'wash'] + wash = rowdatadf.loc[:,'wash'] except KeyError: wash = 0*t try: - catch = rowdatadf.ix[:,'catch'] + catch = rowdatadf.loc[:,'catch'] except KeyError: catch = 0*t try: - finish = rowdatadf.ix[:,'finish'] + finish = rowdatadf.loc[:,'finish'] except KeyError: finish = 0*t try: - peakforceangle = rowdatadf.ix[:,'peakforceangle'] + peakforceangle = rowdatadf.loc[:,'peakforceangle'] except KeyError: peakforceangle = 0*t if data['driveenergy'].mean() == 0: try: - driveenergy = rowdatadf.ix[:,'driveenergy'] + driveenergy = rowdatadf.loc[:,'driveenergy'] except KeyError: driveenergy = power*60/spm else: @@ -1142,7 +1142,7 @@ def dataprep(rowdatadf,id=0,bands=True,barchart=True,otwpower=True, drivelength = driveenergy/(averageforce*4.44822) try: - slip = rowdatadf.ix[:,'slip'] + slip = rowdatadf.loc[:,'slip'] except KeyError: slip = 0*t @@ -1216,11 +1216,11 @@ def dataprep(rowdatadf,id=0,bands=True,barchart=True,otwpower=True, if otwpower: try: - nowindpace = rowdatadf.ix[:,'nowindpace'] + nowindpace = rowdatadf.loc[:,'nowindpace'] except KeyError: nowindpace = p try: - equivergpower = rowdatadf.ix[:,'equivergpower'] + equivergpower = rowdatadf.loc[:,'equivergpower'] except KeyError: equivergpower = 0*p+50. diff --git a/rowers/tasks.py b/rowers/tasks.py index 5e8059f9..388dc793 100644 --- a/rowers/tasks.py +++ b/rowers/tasks.py @@ -1032,7 +1032,7 @@ def handle_sendemail_breakthrough(workoutid, useremail, d = { 'first_name':userfirstname, 'siteurl':siteurl, - 'workoutid':encoder.encode_hex(workoutid), + 'workoutid':encoder.encode_hex(int(workoutid)), 'btvalues':tablevalues, } diff --git a/rowers/views/statements.py b/rowers/views/statements.py index b2716268..40087500 100644 --- a/rowers/views/statements.py +++ b/rowers/views/statements.py @@ -557,8 +557,13 @@ def get_job_status(jobid): else: try: job = Job.fetch(jobid,connection=redis_connection) + try: + status = job.status + except AttributeError: + status = job.get_status() + summary = { - 'status':job.status, + 'status':status, 'result':job.result, 'started_at':job.started_at }