Skip to content

Add optional imported events to calendar API - #659

Merged
thomasluizon merged 2 commits into
redesign/mainfrom
feature/ticket-937-imported-calendar-events
Sep 29, 2026
Merged

thomasluizon merged 2 commits into
redesign/mainfrom
feature/ticket-937-imported-calendar-events

Conversation

@thomasluizon

@thomasluizon thomasluizon commented Sep 29, 2026 •

Copy link
Copy Markdown
Owner

Change

Adds an optional includeImported query parameter to GET /api/Calendar/events. The default path keeps filtering imported events and keeps the existing response JSON. With the parameter set to true, the response includes fetched events from the caller's selected calendars, sets isImported for each event, and supplies importedHabitId when an active habit is linked. Deleted habits and habits owned by other users do not mark an event imported.

The controller forwards the option in src/Orbit.Api/Controllers/CalendarController.cs. The query and optional response fields live in src/Orbit.Application/Calendar/Queries/GetCalendarEventsQuery.cs. The generated contract in src/Orbit.Api/openapi.json describes the parameter and fields. Focused handler, serialization, and controller tests cover the opt-in and default paths. The optional fields are omitted from default JSON so installed clients receive the same response.

Refs thomasluizon/orbit-tickets#937.

Assumptions

  • The endpoint's existing fetched event window remains the time scope; I rejected adding a day query parameter because this ticket asks for an import option and the endpoint has no day selector.
  • A pending sync suggestion without an active habit is available for import in the opt-in view; I rejected treating suggestion history alone as an imported habit.
  • I treated the existing includeImported contract as complete and changed the handler rather than the DTO or OpenAPI snapshot. The alternative was to revise the contract, which this finding did not require.

Test evidence

  • Before the change, dotnet test tests/Orbit.Application.Tests/Orbit.Application.Tests.csproj --filter 'FullyQualifiedName~GetCalendarEventsQueryHandlerTests.Handle_FiltersOutAlreadyImportedHabitsByGoogleEventId' -v normal passed one test with the opt-in defect present.
  • Before the implementation, dotnet test tests/Orbit.Application.Tests/Orbit.Application.Tests.csproj --no-restore --filter 'FullyQualifiedName~Handle_IncludeImported_ReturnsImportedAndAvailableEvents' -v quiet failed with CS1739 because GetCalendarEventsQuery had no IncludeImported parameter. The new behavior could not execute until its contract existed.
  • After the implementation, dotnet test tests/Orbit.Application.Tests/Orbit.Application.Tests.csproj --no-restore --filter 'FullyQualifiedName~GetCalendarEventsQueryHandlerTests|FullyQualifiedName~CalendarEventItemSerializationTests' -v minimal passed 80 tests. dotnet test tests/Orbit.Infrastructure.Tests/Orbit.Infrastructure.Tests.csproj --filter 'FullyQualifiedName~CalendarControllerTests' -v minimal passed 15 tests.
  • dotnet build Orbit.slnx -v minimal completed with zero errors. dotnet test -v minimal passed all 8,148 tests.
  • The existing Handle_ShiftedMultiDayAlternateWeekRule_OmitsEvent test passed before changes: dotnet test tests/Orbit.Application.Tests --filter 'FullyQualifiedName~Handle_ShiftedMultiDayAlternateWeekRule_OmitsEvent' --no-restore.
  • After adding the linked-habit assertion, the same command failed with “Expected importedResult.Value to contain a single item, but the collection is empty.”
  • After the handler fix, the same command passed. dotnet build Orbit.slnx --no-restore completed with zero errors, and dotnet test --no-restore passed all 8,148 tests.

Manual steps

None.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

The opt-in response can still hide previously imported recurring events when their schedule cannot be projected into the account timezone.

Reviewed changes Adds an opt-in import status view to the existing calendar events response while leaving the default JSON unchanged.

  • HTTP and contract: The controller forwards includeImported; OpenAPI describes the query parameter and response fields.
  • Event query: The opt-in path maps active, user-owned habits by Google event ID and annotates fetched events with import status and linked habit ID.
  • Coverage: Handler, controller, and serialization tests cover the default and opt-in paths.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using GPT Sol | 𝕏

Comment thread src/Orbit.Application/Calendar/Queries/GetCalendarEventsQuery.cs

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes Re-reviewed the linked recurring-event fix in 1b105175 against the full calendar API diff.

  • Linked event visibility: Preserved opt-in events linked to active habits even when their recurrence cannot be projected for a new import.
  • Regression coverage: Extended the recurring-event handler test to verify linked events appear in the opt-in response while unlinked events and the default response remain filtered.

Pullfrog  | View workflow run | Using GPT Sol | 𝕏

@thomasluizon
thomasluizon merged commit 40efecf into redesign/main Sep 29, 2026
22 checks passed
@thomasluizon
thomasluizon deleted the feature/ticket-937-imported-calendar-events branch September 29, 2026 10:36
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.

1 participant