Leading zeroes

main
Bob Mottram 2021-10-20 16:48:19 +01:00
parent b0c8b5439c
commit 45a02233fb
1 changed files with 12 additions and 2 deletions

View File

@ -57,8 +57,18 @@ def sortedWatchPoints(fitness: {}, fitnessId: str) -> []:
for watchPoint, item in fitness['performance'][fitnessId].items(): for watchPoint, item in fitness['performance'][fitnessId].items():
if not item.get('total'): if not item.get('total'):
continue continue
averageTime = item['total'] * 1000 / item['ctr'] averageTimeStr = str(item['total'] * 1000 / item['ctr'])
result.append(str(averageTime) + ' ' + watchPoint) if item['total'] < 10:
averageTimeStr = '0' + averageTimeStr
if item['total'] < 100:
averageTimeStr = '0' + averageTimeStr
if item['total'] < 1000:
averageTimeStr = '0' + averageTimeStr
if item['total'] < 10000:
averageTimeStr = '0' + averageTimeStr
if item['total'] < 100000:
averageTimeStr = '0' + averageTimeStr
result.append(averageTimeStr + ' ' + watchPoint)
result.sort(reverse=True) result.sort(reverse=True)
return result return result