Add watch collection for Google Calendar push notification channel data#1101
Merged
victor-enogwe merged 7 commits intomainfrom Oct 13, 2025
Merged
Add watch collection for Google Calendar push notification channel data#1101victor-enogwe merged 7 commits intomainfrom
victor-enogwe merged 7 commits intomainfrom
Conversation
…eate collection migration Co-authored-by: victor-enogwe <23452630+victor-enogwe@users.noreply.github.com>
…ndling Co-authored-by: victor-enogwe <23452630+victor-enogwe@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add new watch collection for Google Calendar notifications
Add watch collection for Google Calendar push notification channel data
Oct 13, 2025
victor-enogwe
approved these changes
Oct 13, 2025
Contributor
There was a problem hiding this comment.
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 <175728472+Copilot@users.noreply.github.com>
victor-enogwe
added a commit
that referenced
this pull request
Oct 24, 2025
…#1101) * Initial plan * Add watch collection schema, types, mongo service integration, and create collection migration Co-authored-by: victor-enogwe <23452630+victor-enogwe@users.noreply.github.com> * Add events watch data migration with comprehensive tests and error handling Co-authored-by: victor-enogwe <23452630+victor-enogwe@users.noreply.github.com> * ✨ 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 <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: victor-enogwe <23452630+victor-enogwe@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.
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.