Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a 'before' argument for the function get_logged_in_athlete_activi… #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
6 changes: 4 additions & 2 deletions stravaio.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def get_activity_by_id(self, id, include_all_efforts=False):
"""
return Activity(self.activities_api.get_activity_by_id(id, include_all_efforts=include_all_efforts))

def get_logged_in_athlete_activities(self, after=0, list_activities=None):
def get_logged_in_athlete_activities(self, after=0, before=0, list_activities=None):
"""List all activities after a given date

Parameters
Expand All @@ -85,6 +85,7 @@ def get_logged_in_athlete_activities(self, after=0, list_activities=None):
If integer, the time since epoch is assumed
If str, the maya.parse() compatible date string is expected e.g. iso8601 or 2018-01-01 or 20180101
If datetime, the datetime object is expected
before: similar to 'after'

Returns
-------
Expand All @@ -94,7 +95,8 @@ def get_logged_in_athlete_activities(self, after=0, list_activities=None):
if list_activities is None:
list_activities = []
after = date_to_epoch(after)
_fetched = self.activities_api.get_logged_in_athlete_activities(after=after)
before = date_to_epoch(before)
_fetched = self.activities_api.get_logged_in_athlete_activities(after=after, before=before)
if len(_fetched) > 0:
print(f"Fetched {len(_fetched)}, the latests is on {_fetched[-1].start_date}")
list_activities.extend(_fetched)
Expand Down