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.

property avg_length: float

Average length, in m.

property avg_speed: float

Average speed, in m/s.

count: int = 0

Number of tracks added.

downhill: float = 0.0

Total downhill, in meters.

classmethod from_tracks(tracks)

Create a new stats collection from this list of tracks.

Parameters:

tracks (List[TrackWithMetadata]) – List of tracks.

Return type:

CumulativeStats

Returns:

The stats.

length: float = 0.0

Total length, in meters.

longest_distance_track: Optional[TrackWithMetadata] = None

The track with the longest distance.

longest_duration_track: Optional[TrackWithMetadata] = None

The track with the longest time.

max_speed: float = 0.0

Overall maximum speed, in m/s.

moving_time: timedelta = datetime.timedelta(0)

Total time spent moving.

shortest_distance_track: Optional[TrackWithMetadata] = None

The track with the shortest distance.

shortest_duration_track: Optional[TrackWithMetadata] = None

The track with the shortest time.

stopped_time: timedelta = datetime.timedelta(0)

Total time standing still.

uphill: float = 0.0

Total uphill, in meters.

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:

List[TrackWithMetadata]

Returns:

All tracks.

stats()

Returns the stats for all tracks in this summary.

Return type:

CumulativeStats

Returns:

The stats.

property total_length: float

Returns the total length of all tracks in this summary.

Returns:

The total length in meters.

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:

List[TrackWithMetadata]

Returns:

All tracks.

stats()

Returns the stats for all tracks in this summary.

Return type:

CumulativeStats

Returns:

The stats.

property total_length: float

Returns the total length of all tracks in this summary.

Returns:

The total length in meters.

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:

List[TrackWithMetadata]

Returns:

All tracks.

stats()

Returns the stats for all tracks in this summary.

Return type:

CumulativeStats

Returns:

The stats.

property total_length: float

Returns the total length of all tracks in this summary.

Returns:

The total length in meters.