[MSD benchmark] feat: add calendar cache status and actions#10
Open
khaliqgant wants to merge 28 commits into
Open
[MSD benchmark] feat: add calendar cache status and actions#10khaliqgant wants to merge 28 commits into
khaliqgant wants to merge 28 commits into
Conversation
- Add updatedAt field to CalendarCache schema with migration - Create tRPC cacheStatus endpoint for fetching cache timestamps - Add action dropdown to CalendarSwitch for Google Calendar entries - Display formatted last updated timestamp in dropdown - Add placeholder for cache deletion functionality - Include translation strings for dropdown content The dropdown only appears for Google Calendar integrations that have active cache entries and provides cache management options for future extensibility. Co-Authored-By: zomars@cal.com <zomars@me.com>
- Remove problematic satisfies clause in selectedCalendar.ts - Add missing cacheStatus parameter to ConnectedCalendarList component - Fixes type errors that were preventing CI from passing Co-Authored-By: zomars@cal.com <zomars@me.com>
- Remove separate cacheStatus tRPC endpoint as requested - Return cache status as separate field in connectedCalendars response - Update UI components to use cache data from connectedCalendars - Fix Prisma type incompatibilities in repository files Co-Authored-By: zomars@cal.com <zomars@me.com>
…e status - Fix Prisma.SortOrder usage in membership.ts orderBy clauses - Remove problematic satisfies clause in selectedCalendar.ts - Fix TeamSelect type reference in team.ts - Update SelectedCalendarsSettingsWebWrapper to properly pass cacheStatus data flow Co-Authored-By: zomars@cal.com <zomars@me.com>
…ription logic - Fix timestamp HTML entity encoding with interpolation escapeValue: false - Only show dropdown for subscribed Google calendars (googleChannelId exists) - Hide delete option when no cache data exists - Include updatedAt and googleChannelId fields upstream in user repository - Update data flow to pass subscription status through components Co-Authored-By: zomars@cal.com <zomars@me.com>
…cache refresh - Add updateManyByCredentialId method to SelectedCalendarRepository - Update fetchAvailabilityAndSetCache to refresh SelectedCalendar timestamps - Ensure webhook flow updates both CalendarCache and SelectedCalendar records - Maintain proper timestamp tracking for calendar cache operations Co-Authored-By: zomars@cal.com <zomars@me.com>
Introduces test-gcal-webhooks.sh to start Tunnelmole, extract the public URL, and update GOOGLE_WEBHOOK_URL in the .env file. Handles process management, rate limits, and ensures environment configuration for Google Calendar webhooks.
Replaces 'ts-node' with 'npx tsx' in the dev:cron script for running cron-tester.ts, likely to improve compatibility or leverage tsx features.
Renamed 'last_updated' to 'cache_last_updated' in locale file for clarity and updated CalendarSwitch to use the new string. Also added dark mode text color support for cache status display.
…ove App - Create CredentialActionsDropdown component consolidating cache and app removal actions - Add deleteCache tRPC mutation for credential-level cache deletion - Update connectedCalendars handler to include cacheUpdatedAt at credential level - Move dropdown from individual CalendarSwitch to credential level in SelectedCalendarsSettingsWebWrapper - Remove cache-related props from CalendarSwitch component - Add translation strings for cache management actions - Consolidate all credential-level actions (cache management + Remove App) in one dropdown Co-Authored-By: zomars@cal.com <zomars@me.com>
- Remove duplicate cache-related keys at lines 51-56 - Keep properly positioned keys later in file - Addresses GitHub comment from zomars about duplicate keys Co-Authored-By: zomars@cal.com <zomars@me.com>
- Address GitHub comment from zomars - Rename 'last_updated' to 'cache_last_updated' for specificity - Update usage in CredentialActionsDropdown component Co-Authored-By: zomars@cal.com <zomars@me.com>
Co-Authored-By: zomars@cal.com <zomars@me.com>
…ttern - Add confirmation dialog for destructive cache deletion action - Replace direct Prisma calls with CalendarCacheRepository pattern - Add getCacheStatusByCredentialIds method to repository interface - Fix import paths for UI components - Address GitHub review comments from zomars Co-Authored-By: zomars@cal.com <zomars@me.com>
- Remove wrapping div around DisconnectIntegration component - Fixes nested <p> tag validation error preventing Remove App functionality - Maintains existing confirmation dialog patterns Co-Authored-By: zomars@cal.com <zomars@me.com>
Removed unnecessary return values after setting status in the integrations API handler. This clarifies response handling and prevents returning the response object when not needed. Resolves "API handler should not return a value, received object".
Replaces the DisconnectIntegration component with an inline confirmation dialog for removing app credentials. Adds disconnect mutation logic and updates UI to improve user experience and consistency.
Added a default value of NOW() for the updatedAt column in the CalendarCache table to ensure existing and future rows have a valid timestamp. Updated the Prisma schema to reflect this change and provide compatibility for legacy data and raw inserts.
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.
MSD benchmark PR recreated from Martian Code Review Bench.
Source PR: calcom#22532
Dataset: cal_dot_com
Original title: feat: add calendar cache status and actions
Summary
This pull request introduces a new feature to manage calendar cache data, including the ability to view cache status and delete cached data. It also includes several supporting updates to repositories, APIs, and UI components. Below is a summary of the most important changes grouped by theme.
New Feature: Calendar Cache Management
deleteCachemutation to the TRPCcalendarsRouter, enabling users to delete cached calendar data by credential ID. ([packages/trpc/server/routers/viewer/calendars/_router.tsxR27-R33](https://github.com/MSD-Benchmarks/cal.diy/pull/10/files#diff-9e053175cc6dfb5717313e0587a730fff132f9d3c1200204f0ce8dac53a19280R27-R33))deleteCacheHandlerto handle cache deletion logic, including validation of user access to the specified credential. ([packages/trpc/server/routers/viewer/calendars/deleteCache.handler.tsR1-R33](https://github.com/MSD-Benchmarks/cal.diy/pull/10/files#diff-572888b8e0555167a5787847f29d5a46623eff170491acc0654e916f5b4afd18R1-R33))connectedCalendarsHandlerto enrich calendar data with cache status (cacheUpdatedAt) by querying theCalendarCacheRepository. ([packages/trpc/server/routers/viewer/calendars/connectedCalendars.handler.tsR27-R39](https://github.com/MSD-Benchmarks/cal.diy/pull/10/files#diff-3f6a556ad60f26d0162770fcd81b5bddeb6ab0437552ac792045c3cd2608d710R27-R39))UI Enhancements
CredentialActionsDropdowncomponent to display cache status and provide options to delete cached data or disconnect integrations. ([packages/features/apps/components/CredentialActionsDropdown.tsxR1-R134](https://github.com/MSD-Benchmarks/cal.diy/pull/10/files#diff-c78273434b95ab8276bb5eb24d9bc088b10af029388bdcd08cbe478f44269b31R1-R134))DisconnectIntegrationcomponent withCredentialActionsDropdownin theSelectedCalendarsSettingsWebWrapperUI, integrating the new cache management functionality. ([[1]](https://github.com/MSD-Benchmarks/cal.diy/pull/10/files#diff-831b0874e07f01721f87926262c5c9674ff9d7443741dfb71ceb849656345b00L5-R5),[[2]](https://github.com/MSD-Benchmarks/cal.diy/pull/10/files#diff-831b0874e07f01721f87926262c5c9674ff9d7443741dfb71ceb849656345b00L70-L81),[[3]](https://github.com/MSD-Benchmarks/cal.diy/pull/10/files#diff-831b0874e07f01721f87926262c5c9674ff9d7443741dfb71ceb849656345b00L125-L135))Repository and Database Updates
getCacheStatusByCredentialIdsmethod to theCalendarCacheRepositoryand its mock implementation to fetch cache statuses for multiple credentials. ([[1]](https://github.com/MSD-Benchmarks/cal.diy/pull/10/files#diff-b36c72c0db751ba0cafe234dfa150817672869825333c22b074c4977a6135b8dR30-R32),[[2]](https://github.com/MSD-Benchmarks/cal.diy/pull/10/files#diff-ceffbae9ef3da413495feac73a341672e77ffaf493cf67ada0b637ead80ded38R26-R30),[[3]](https://github.com/MSD-Benchmarks/cal.diy/pull/10/files#diff-4cf8d3089fad7b6c8fe4172d8d42147f136b65baf30b726e57b9b10d179d4a99R172-R188))updateManyByCredentialIdmethod in theSelectedCalendarRepositoryto update multiple calendars by credential ID. ([packages/lib/server/repository/selectedCalendar.tsR400-R406](https://github.com/MSD-Benchmarks/cal.diy/pull/10/files#diff-ccb4eecfa701e5b0c7d6ba87dcc550cdf3700a63ee252849045611599ecb9273R400-R406))updatedAtcolumn to theCalendarCachetable in the database schema and Prisma model to track the last update timestamp. ([[1]](https://github.com/MSD-Benchmarks/cal.diy/pull/10/files#diff-9f597bd98bbcfdcf4861ee7bf0c238e7dfe54b456ceb69b852aaf3979c4102cfR1-R8),[[2]](https://github.com/MSD-Benchmarks/cal.diy/pull/10/files#diff-56fa4d384ba6fb94b130e9eb42c5cad00734b025ebd6c197f76873469725ae87R1718))Localization and Strings
[apps/web/public/static/locales/en/common.jsonR3376-R3382](https://github.com/MSD-Benchmarks/cal.diy/pull/10/files#diff-57de4b8e5231f1d699891d98b0381d56e9e24537b0ca5420d1fba4f0597370bcR3376-R3382))Miscellaneous
package.jsonto replacets-nodewithnpx tsxfor running thedev:cronscript. ([apps/web/package.jsonL11-R11](https://github.com/MSD-Benchmarks/cal.diy/pull/10/files#diff-14b60f636e1a2b0061da57aaf231cb1ed15a5dc0c592425ed82e58fec95d42d8L11-R11))Review & Testing Checklist for Human
🔴 High Priority (5 items)
trpc.viewer.calendars.deleteCache.useMutation()but this mutation implementation is not visible in the PR changes. Check if this endpoint exists or needs to be created.cacheUpdatedAttimestamps are correctly formatted and displayed only for Google Calendar credentials with actual cache data.getCacheStatusByCredentialIds()returns accurate data and the credential-to-cache mapping works properly in the UI.Recommended Test Plan:
/apps/installed/calendarDiagram
%%{ init : { "theme" : "default" }}%% graph TD UI["CredentialActionsDropdown.tsx<br/>(New Component)"]:::major-edit Handler["connectedCalendars.handler.ts<br/>(Updated tRPC Handler)"]:::major-edit RepoInterface["calendar-cache.repository.interface.ts<br/>(Updated Interface)"]:::minor-edit RepoImpl["calendar-cache.repository.ts<br/>(Updated Implementation)"]:::minor-edit RepoMock["calendar-cache.repository.mock.ts<br/>(Updated Mock)"]:::minor-edit Translations["common.json<br/>(Added Translation Keys)"]:::minor-edit UI -->|"Uses repository via tRPC"| Handler Handler -->|"Calls getCacheStatusByCredentialIds"| RepoImpl RepoImpl -->|"Implements"| RepoInterface RepoMock -->|"Implements"| RepoInterface UI -->|"Uses translation keys"| Translations subgraph Legend L1[Major Edit]:::major-edit L2[Minor Edit]:::minor-edit L3[Context/No Edit]:::context end classDef major-edit fill:#90EE90 classDef minor-edit fill:#87CEEB classDef context fill:#FFFFFFNotes
cacheUpdatedAtfrom CalendarCache. Consider if SelectedCalendar.updatedAt update should be removed.