feat: Strava Integration (OAuth, Jobs, UI)#114
Merged
Conversation
…encrypted credentials
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Introduces a fully featured, robust, and lightweight integration with the Strava API to automatically sync athletes' activities into Calcpace Web, extracting vital data and estimating VO2 Max natively.
Technical Highlights 🚀
This implementation intentionally avoids bloated third-party gems, favoring a lean, native Rails approach with several architectural highlights:
ActiveRecord::Encryption.Strava::ClientwrappingNet::HTTPto handle OAuth flow, token refreshing, and paginated data fetching without external dependencies.StravaSyncJobvia ActiveJob/SolidQueue. It paginates up to 2,000 historical runs per sync, gracefully handling API rate limits, HTTP errors, and token expirations in the background.summary_polyline. This encrypted string is saved in a single text column and decoded seamlessly via JavaScript on the frontend using Leaflet, delivering high-performance maps with zero storage overhead.Strava::ActivityImporterenforces single responsibility. It filters out non-running activities (supportsRun,TrailRun,Walk), deduplicates byexternal_id, and maps distance/time/elevation/HR directly to the Calcpace engine for automatic VO2 Max estimation.StravaWebhooksController) with challenge validation and async job triggering, ensuring the app is ready for real-time push events.Changes
db/migrate: AddedStravaAccounttable (with encrypted tokens) andmap_polylinetoactivities.app/models: AddedStravaAccountmodel and updatedActivity.log.app/lib/strava: CreatedClientandActivityImporter.app/jobs: AddedStravaSyncJob.app/controllers: AddedStravaAccountsController(OAuth callback) andStravaWebhooksController.app/views: Added Connect/Disconnect UI inaccounts/showusingjet_uiand implemented JS Polyline decoding in_map.html.erb.Testing
WebMockto simulate Strava API responses, token expirations, and webhook challenge validations.How to test manually
bin/dev