Skip to content

Exploratory Google Calendar API integration#114

Draft
Copilot wants to merge 4 commits intomainfrom
copilot/exploratory-google-calendar-api
Draft

Exploratory Google Calendar API integration#114
Copilot wants to merge 4 commits intomainfrom
copilot/exploratory-google-calendar-api

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 6, 2026

Adds foundational plumbing for syncing training plan workouts to Google Calendar. Follows the existing Strava integration patterns: service object → background jobs → model callbacks.

Data model

  • users.google_calendar_id — persistent calendar ID per user
  • plans.calendar_sync_enabled — per-plan sync toggle
  • activities.google_calendar_event_id — tracks synced events

GoogleCalendarService

Handles all Calendar API interactions via google-apis-calendar_v3: find/create a dedicated "Lace Training" calendar, CRUD events as all-day entries, and refresh Google OAuth tokens via Signet.

service = GoogleCalendarService.new(user)
service.sync_plan(plan)         # bulk sync all activities
service.update_event(activity)  # single event upsert
service.delete_event(cal_id, event_id)

Background jobs

  • SyncPlanToCalendarJob — bulk sync on enable
  • RemovePlanCalendarEventsJob — bulk remove on disable
  • UpdateCalendarEventJob — triggered by activity after_update
  • DeleteCalendarEventJob — triggered by activity before_destroy

Model callbacks

  • Plan: after_update enqueues sync/remove when calendar_sync_enabled changes
  • Activity: after_update enqueues event update on distance/description/date change; before_destroy enqueues event deletion

OAuth scope

Google OAuth now requests https://www.googleapis.com/auth/calendar with access_type: "offline".

UI

Toggle button on plan show page, visible only when user has a connected Google account.

Notes

  • User#has_google_access_token? uses parameterized raw SQL to check token presence without triggering ActiveRecord encryption decryption — works around a pre-existing issue where test env lacks encryption credentials.
  • 24 new tests covering service, jobs, and model callbacks.
Original prompt

Make an exploratory PR for Google Calendar API integration


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits March 6, 2026 12:40
…model callbacks, and UI toggle

Co-authored-by: apdarr <3004606+apdarr@users.noreply.github.com>
…xisting failures unchanged

Co-authored-by: apdarr <3004606+apdarr@users.noreply.github.com>
…e UTC timezone for calendar

Co-authored-by: apdarr <3004606+apdarr@users.noreply.github.com>
Copilot AI changed the title [WIP] Exploratory integration with Google Calendar API Exploratory Google Calendar API integration Mar 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants