-
Notifications
You must be signed in to change notification settings - Fork 51
Add watch collection for Google Calendar push notification channel data #1101
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
Conversation
…eate collection migration Co-authored-by: victor-enogwe <[email protected]>
…ndling Co-authored-by: victor-enogwe <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a dedicated watch collection for storing Google Calendar push notification channel data, separating it from existing sync data to improve performance and reduce operational complexity.
Key changes include:
- New watch collection schema with TypeScript types and MongoDB validation
- Database migrations for collection creation and non-destructive data migration from sync to watch collection
- MongoService integration with proper indexes for efficient querying
Reviewed Changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
packages/core/src/types/watch.types.ts |
Defines the watch schema and TypeScript types for notification channel data |
packages/core/src/types/type.utils.ts |
Moves ObjectId utility functions for reuse across the codebase |
packages/backend/src/common/constants/collections.ts |
Adds watch collection constant with dev/prod environment support |
packages/backend/src/common/services/mongo.service.ts |
Integrates watch collection with proper TypeScript types and collection getter |
packages/scripts/src/migrations/2025.10.13T14.18.20.watch-collection.ts |
Creates watch collection with schema validation and performance indexes |
packages/scripts/src/migrations/2025.10.13T14.22.21.migrate-sync-watch-data.ts |
Migrates existing events watch data to new collection while creating fresh notification channels |
packages/scripts/src/migrations/2025.10.13T14.22.21.migrate-sync-watch-data.ts
Outdated
Show resolved
Hide resolved
packages/scripts/src/migrations/2025.10.13T14.22.21.migrate-sync-watch-data.ts
Outdated
Show resolved
Hide resolved
…nc-watch-data.ts Co-authored-by: Copilot <[email protected]>
…#1101) * Initial plan * Add watch collection schema, types, mongo service integration, and create collection migration Co-authored-by: victor-enogwe <[email protected]> * Add events watch data migration with comprehensive tests and error handling Co-authored-by: victor-enogwe <[email protected]> * ✨ feat(sub-calendars): update watch schema and tests * :sparkles feat(sub-calendars): update watch collection schema and tests * Update packages/scripts/src/migrations/2025.10.13T14.22.21.migrate-sync-watch-data.ts Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: victor-enogwe <[email protected]> Co-authored-by: Copilot <[email protected]>
Overview
This PR introduces a new
watchcollection to store Google Calendar push notification channel metadata separately from sync data. This separation improves query performance and reduces the risk of errors during watch operations by isolating channel lifecycle management from sync token operations.What Changed
New Watch Collection Schema
Added a dedicated
watchcollection with the following schema:Database Integration
WATCHcollection constant with dev/prod environment supportuserIdindex for efficient user-based queriesuserId + expirationcompound index for cleanup operationsMigrations
Collection Creation (
2025.10.13T14.18.20.watch-collection.ts)Creates the watch collection with MongoDB schema validation and indexes.
Data Migration (
2025.10.13T14.22.21.migrate-events-watch-data.ts)Non-destructive migration that copies existing events watch data from the sync collection to the new watch collection. The migration:
Technical Details
Before
Watch channel data was embedded within sync documents:
After
Watch channel data has its own dedicated collection:
Benefits
Testing
Comprehensive test coverage includes:
All existing tests continue to pass, confirming backward compatibility.
Migration Safety
Both migrations are designed for safe production deployment:
The migrations will be executed in a separate deployment as noted in the issue requirements.
Original prompt
Fixes #1100
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.