Removes the need to create files for each saved activity - db-only now!
involves re-reading the strava data for each detail view. Which I think is ok since it's a single-user app. And hey, strava api requests are a form of analytics too...
[x] Add a button to the admin dashboard or activity list to add all activities
[x] #68
[x] Make sure not to (try to) add duplicate activities
Related: #38
[x] Batch operation backend
[x] #57
[x] accepts a stravalib client ^(edit: not serializable) a strava account id and a list of strava activity ids
[x] Accepts settings describing how to save the activities
[x] "Which activities to keep in the case of overlap?" {existing, incoming, both} -> (if an activity has a distinct strava id from a saved activity, but its start and end times overlap with those of the saved activity, it's likely a duplicate).
For now, everything but 'both' is allowed. Can't think of a use case for it atm.
[x] "Save walks and hikes as runs?" -> otherwise, these activities are ignored
For now, pinned checked. The default behavior is for walks to be treated the same.
[x] (later) "Save bike rides?" -> requires completely different metrics and stuff; tempting one day though.
For now, pinned unchecked. Now I just need the backend to actually avoid saving bike rides.
[x] Works with rate limiting (stravalib/strava api).
Idea is to configure the batch operation so it either:
✔️ Is allowed to make too many requests, and then work with the error message so it can continue the operation when back under the rate limit.
Knows the strava API short-term limit of 600/15 minutes, and it schedules the operations to avoid it.
Other tasks that popped up
Issues batch-importing a manually-created activity. Since there was no stream data, causing client.get_activity_streams() to return None. I fixed this by adding a check for the existence of activity streams before passing to the analysis function.
File "/home/aaron/aaron-schroeder/distilling-flask-deploy/application/tasks.py", line 69, in async_save_strava_activities
df = converters.from_strava_streams(client.get_activity_streams(
File "/home/aaron/aaron-schroeder/distilling-flask-deploy/application/converters.py", line 29, in from_strava_streams
stream_data_dict = {key: stream.data for key, stream in streams.items()}
AttributeError: 'NoneType' object has no attribute 'items'
Related to the task above: the activity log view needed to gracefully handle an activity with tss = 0. Caused a break in the running averages for ATL and CTL. To fix, I just set na values in the TSS column to 0.
stravalib client^(edit: not serializable) a strava account id and a list of strava activity idsOther tasks that popped up
client.get_activity_streams()
to return None. I fixed this by adding a check for the existence of activity streams before passing to the analysis function.