Changeset 3ac70ca in OpenWorkouts-current for ow/views/user.py
- Timestamp:
- Mar 12, 2019, 9:29:22 PM (5 years ago)
- Branches:
- current
- Children:
- 39dc0a6
- Parents:
- f2c9e20
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
ow/views/user.py
rf2c9e20 r3ac70ca 466 466 'distance': 0, # kilometers 467 467 'elevation': 0, # meters 468 'workouts': 0, 469 'sports': {}, 468 470 } 469 471 duration = getattr(workout, 'duration', None) or timedelta(0) … … 473 475 elevation = getattr(workout, 'uphill', None) or 0 474 476 stats[start]['elevation'] += int(elevation) 477 stats[start]['workouts'] += 1 478 if workout.sport not in stats[start]['sports'].keys(): 479 stats[start]['sports'][workout.sport] = 0 480 stats[start]['sports'][workout.sport] += 1 475 481 476 482 json_stats = [] … … 484 490 str(hms[1]).zfill(2), localizer.translate(_('min.')) 485 491 ]) 492 distance_formatted = str(round(stats[day]['distance'])) + ' km' 493 elevation_formatted = str(round(stats[day]['elevation'])) + ' m' 486 494 json_stats.append({ 487 495 'day': day, … … 489 497 'time_formatted': time_formatted, 490 498 'distance': stats[day]['distance'], 491 'elevation': stats[day]['elevation'] 499 'distance_formatted': distance_formatted, 500 'elevation': stats[day]['elevation'], 501 'elevation_formatted': elevation_formatted, 502 'workouts': stats[day]['workouts'], 503 'sports': stats[day]['sports'] 492 504 }) 493 505
Note: See TracChangeset
for help on using the changeset viewer.