Closed mdrovdahl closed 5 years ago
Keep in mind there are basically 2 different kinds of imports: "initial" and "ongoing".
For most of the other ones, I've built logic into the build_url
method which handles each type differently, with the general rule of thumb that for the "initial" import, I start from "now" and work backwards, and for "ongoing" imports I try to start from the last-imported, and then work up to "now".
From what you've described above, I think the first import could use the first_date
as the after
param, and then page through them all. Then for the "ongoing"/auto imports, you'd just use the date of the most-recently imported activity for after
, and get whatever new ones were available (again, paging through things, just in case).
@mdrovdahl Any progress on this? Care to collaborate? I'm interested in this and will likely build it in the next few weeks if you haven't already. :)
Hi @ethitter =)
I finally got a few moments to work on this during my GM class...see #23
Closed via #23
With the Strava service definition in https://github.com/beaulebens/keyring/issues/25 I'm now working on an importer for Strava. I've been basing it on and borrowing from the existing Moves importer.
One architectural decision I'm pondering...when the Strava keyring connection is created, I'm storing a
first_date
which is the profilecreated_at
aka "The time at which the athlete was created." from the SummaryAthlete response to https://www.strava.com/oauth/token (ref: https://developers.strava.com/docs/reference/#api-models-SummaryAthlete)So, assuming that the activities we want to import are from dates greater than
first_date
...how best to gather them for importing?The Strava athlete/activities endpoint supports date filtering via
before
andafter
params in (unix epoch format), but they can't be combined =(eg: https://www.strava.com/api/v3/athlete/activities?after=1515801600 where after == Saturday 13th January 2018 12:00:00 AM
So, I guess we'll ask the Strava athlete/activities endpoint for ALL activities after
first_date
and then page through them (endpoint defaults to 30 activities per page) until we're done.I guess that's the approach I'll take, unless anyone has better ideas =)