fietsboek.summaries module¶
Module for a yearly/monthly track summary.
- class fietsboek.summaries.CumulativeStats(count=0, length=0.0, uphill=0.0, downhill=0.0, moving_time=datetime.timedelta(0), stopped_time=datetime.timedelta(0), max_speed=0.0, longest_distance_track=None, shortest_distance_track=None, longest_duration_track=None, shortest_duration_track=None)¶
Bases:
object
Cumulative user stats.
The values start out with default values, and tracks can be merged in via
add()
.- add(track)¶
Adds a track to this stats collection.
- Parameters:
track (
TrackWithMetadata
) – The track to add, with accompanying metadata.
- property avg_duration: timedelta¶
Average duration of a track.
Note that this property is automatically rounded to seconds.
- classmethod from_tracks(tracks)¶
Create a new stats collection from this list of tracks.
- Parameters:
tracks (
List
[TrackWithMetadata
]) – List of tracks.- Return type:
- Returns:
The stats.
-
longest_distance_track:
Optional
[TrackWithMetadata
] = None¶ The track with the longest distance.
-
longest_duration_track:
Optional
[TrackWithMetadata
] = None¶ The track with the longest time.
-
shortest_distance_track:
Optional
[TrackWithMetadata
] = None¶ The track with the shortest distance.
-
shortest_duration_track:
Optional
[TrackWithMetadata
] = None¶ The track with the shortest time.
- class fietsboek.summaries.MonthSummary(month)¶
Bases:
object
A summary over a single month.
- Variables:
month – Month number (1-12).
tracks – List of tracks in this month.
- add(track)¶
Add a track to the summary.
- Raises:
ValueError – If the given track has no date set.
- Parameters:
track (
TrackWithMetadata
) – The track to insert.
- all_tracks()¶
Returns all tracks of the summary.
- Return type:
- Returns:
All tracks.
- stats()¶
Returns the stats for all tracks in this summary.
- Return type:
- Returns:
The stats.
- class fietsboek.summaries.Summary(ascending=True)¶
Bases:
object
A summary of a user’s tracks.
- Variables:
years (dict[int, YearSummary]) – Mapping of year to
YearSummary
.ascending (bool) – If
True
, years will be sorted from old-to-new, otherwise they will be sorted new-to-old.
- add(track)¶
Add a track to the summary.
This automatically inserts the track into the right yearly summary.
- Raises:
ValueError – If the given track has no date set.
- Parameters:
track (fietsboek.model.track.Track) – The track to insert.
- all_tracks()¶
Returns all tracks of the summary.
- Return type:
- Returns:
All tracks.
- stats()¶
Returns the stats for all tracks in this summary.
- Return type:
- Returns:
The stats.
- class fietsboek.summaries.YearSummary(year, ascending=True)¶
Bases:
object
A summary over a single year.
- Variables:
year – Year number.
months – Mapping of month to
MonthSummary
.ascending (bool) – If
True
, months will be sorted from old-to-new, otherwise they will be sorted new-to-old.
- add(track)¶
Add a track to the summary.
This automatically inserts the track into the right monthly summary.
- Raises:
ValueError – If the given track has no date set.
- Parameters:
track (
TrackWithMetadata
) – The track to insert.
- all_tracks()¶
Returns all tracks of the summary.
- Return type:
- Returns:
All tracks.
- stats()¶
Returns the stats for all tracks in this summary.
- Return type:
- Returns:
The stats.