rmdmattingly / RowlogAnalysis

MIT License
5 stars 0 forks source link

Meters and split per boat #31

Closed Logar18 closed 4 years ago

Logar18 commented 4 years ago

This code will return the average total meters each person has, as well as their average split, all based on what boat they were in.

This code is not yet tested as I always get this issue where I can't change capitalization in filenames when I rename them.

@rmdmattingly @taddyb

Logar18 commented 4 years ago

@rmdmattingly @taddyb I made a few changes and got rid of a few bugs but then I realized that there's no split in the API. We can just leave this code here until that function is added.

rmdmattingly commented 4 years ago

@Logar18 good catch, I just added it. Should be keyed as avg_split

Logar18 commented 4 years ago
$ python main.py metersAndSplitPerBoat
Traceback (most recent call last):
  File "main.py", line 75, in <module>
    output = serviceSwitch(parseInput())
  File "main.py", line 73, in serviceSwitch
    return service(arguments)
  File "main.py", line 56, in metersAndSplitPerBoat
    return MetersAndSplitPerBoat.run(getWorkoutData(orderBy='wid', comment=''), getPeopleData(), SplitManager)
  File "C:\Users\lfarm\OneDrive\Documents\GitHub\project-farmer-laibach\RowlogAnalysis\Service\MetersAndSplitPerBoat.py", line 30, in run
    output['1v'] = calculateBoatAverageSplit(workoutData, peopleData, '1v', SplitManager)
  File "C:\Users\lfarm\OneDrive\Documents\GitHub\project-farmer-laibach\RowlogAnalysis\Service\MetersAndSplitPerBoat.py", line 22, in calculateBoatAverageSplit
    totalSplitSeconds += SplitManager.convertSplitToSeconds(SplitManager.parseStringToMinAndSec(workout['avg_split']))
  File "C:\Users\lfarm\OneDrive\Documents\GitHub\project-farmer-laibach\RowlogAnalysis\Core\SplitManager.py", line 12, in convertSplitToSeconds
    min, sec = parseStringToMinAndSec(splitTime)
  File "C:\Users\lfarm\OneDrive\Documents\GitHub\project-farmer-laibach\RowlogAnalysis\Core\SplitManager.py", line 7, in parseStringToMinAndSec
    minsAndSecArr = splitTime.split(':')
AttributeError: 'tuple' object has no attribute 'split'

Getting this error when running through the split manager. I parsed my split through the manager like so:

totalSplitSeconds += SplitManager.convertSplitToSeconds(SplitManager.parseStringToMinAndSec(workout['avg_split']))

@rmdmattingly @taddyb

rmdmattingly commented 4 years ago

Ah, so you don't need to call the parseStringToMinAndSec, those are supposed to be internal to the SplitManager file. I should make it a class so that I can restrict the public/private nature of functions probably.

Just use the convertSplitToSeconds and convertSecondsToSplit methods, those should do exactly what you need.

Logar18 commented 4 years ago

@rmdmattingly Oh good catch. Still getting this error when running it the way I had it before:

  File "C:\Users\lfarm\OneDrive\Documents\GitHub\project-farmer-laibach\RowlogAnalysis\Core\SplitManager.py", line 13, in convertSplitToSeconds
    return calcSeconds(min, sec)
  File "C:\Users\lfarm\OneDrive\Documents\GitHub\project-farmer-laibach\RowlogAnalysis\Core\SplitManager.py", line 4, in calcSeconds
    return (float(min) * 60) + float(sec)
ValueError: could not convert string to float: 'C'
rmdmattingly commented 4 years ago

Ah, that's because missert entered in some 1k ergs with the split C:OR.E lmao. Depending on the context, maybe surround with a try/except and pass on data which generates exceptions because it wouldn't be good data anyway

Logar18 commented 4 years ago

@rmdmattingly that fucker

Logar18 commented 4 years ago

@rmdmattingly I just made him delete the workout. Code should be fully functional now.

taddyb commented 4 years ago

Ban missert from ever entering meters in again

rmdmattingly commented 4 years ago

I haven't tested these changes myself, but assuming you have they look pretty good to me. Just a few nits

rmdmattingly commented 4 years ago

@Logar18 @taddyb I sorta took over the final touches on this bad boi, please look thru the diff to see what I've done, particularly with the BoatManager addition to Core. Should be very useful down the road