Skip to content

Add overlap-aware event time window (EventFilter.activeWindow) - #250

Merged
chrisballinger merged 2 commits into
masterfrom
event-window-overlap
Jul 3, 2026
Merged

Add overlap-aware event time window (EventFilter.activeWindow)#250
chrisballinger merged 2 commits into
masterfrom
event-window-overlap

Conversation

@chrisballinger

Copy link
Copy Markdown
Member

Summary

The shared occurrence query eventOccurrenceRequest(filter:) bounded the time window by the occurrence's start only, so a query for events in [from, to) dropped events that began before from but are still running — the classic interval bug. This surfaced in the AI "Right Now" flow: the region query's start-bounded SQL prefilter dropped in-progress events before the workflow's client-side overlap gate ever saw them.

This fixes it additively rather than flipping the global semantics. A global flip would change two release features ("today's favorites on map" and "today only" favorites), where multi-day occurrences would start appearing on every day they span — inconsistent with how the day-tab buckets by start day.

Changes

  • EventFilter — new activeWindow: DateInterval?, added as the last init parameter to avoid a positional/labeled-arg ordering break. Independent of startDate/endDate, which keep their start-bounded calendar-day meaning. DateInterval is Codable+Hashable, so synthesized conformances still hold.
  • PlayaDBImpl.eventOccurrenceRequest(filter:) — when activeWindow is set, apply the overlap predicate (startTime < window.end && endTime > window.start), the same form as fetchEvents(from:to:).
  • RightNowWorkflow.regionQuery — use activeWindow instead of startDate/endDate, with a guard floor < windowEnd so an empty/past window can't form an inverted DateInterval. The region query now surfaces events already underway at floor. The client-side overlap gate stays (it unifies the separately-fetched camp/art-hosted occurrences).

This is the documented Phase A2 prerequisite for unifying Nearby / Right Now, and independently fixes a real bug in the AI "Right Now" flow.

Test

testEventOccurrenceRequestActiveWindowKeepsInProgressEvents documents both behaviors so the distinction can't silently regress: start-bounded filtering returns ["in-window"], while activeWindow returns ["ongoing", "in-window"] (keeping the in-progress event, excluding ended/future ones).

Verification

  • PlayaDB FilterRequestBuilderTests: 15/15 pass
  • iBurn build (iPhone 17 Pro Max, iOS 26.2): 0 errors, 6 pre-existing warnings (unrelated files)

🤖 Generated with Claude Code

chrisballinger and others added 2 commits June 23, 2026 20:33
The shared occurrence query (`eventOccurrenceRequest(filter:)`) bounded the
time window by the occurrence's START only, so a query for events in
[from, to) dropped events that began before `from` but are still running —
the classic interval bug. This surfaced in the AI "Right Now" flow: the
region query's start-bounded SQL prefilter dropped in-progress events before
the workflow's client-side overlap gate ever saw them.

Fix additively rather than flipping the global semantics (a global flip would
change "today's favorites on map" and "today only" favorites — multi-day
occurrences would appear on every day they span):

- EventFilter: new `activeWindow: DateInterval?`, added as the LAST init
  parameter to avoid the positional/labeled-arg ordering break. Independent of
  startDate/endDate, which keep their start-bounded calendar-day meaning.
- PlayaDBImpl.eventOccurrenceRequest: when activeWindow is set, apply the
  overlap predicate (startTime < window.end && endTime > window.start), same
  form as fetchEvents(from:to:).
- RightNowWorkflow.regionQuery: use activeWindow instead of startDate/endDate,
  with a `guard floor < windowEnd` so an empty/past window can't form an
  inverted DateInterval. Now surfaces events already underway at `floor`.

Test: testEventOccurrenceRequestActiveWindowKeepsInProgressEvents documents
both behaviors (start-bounded returns ["in-window"]; activeWindow returns
["ongoing", "in-window"]) so the distinction can't silently regress.

Verified: PlayaDB FilterRequestBuilderTests 15/15; iBurn build 0 errors.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JzbeRndzvsespqfgqxaJs3
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JzbeRndzvsespqfgqxaJs3
@chrisballinger
chrisballinger merged commit b4fbde6 into master Jul 3, 2026
0 of 4 checks passed
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