Add overlap-aware event time window (EventFilter.activeWindow) - #250
Merged
Conversation
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
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.
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 beforefrombut 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— newactiveWindow: DateInterval?, added as the last init parameter to avoid a positional/labeled-arg ordering break. Independent ofstartDate/endDate, which keep their start-bounded calendar-day meaning.DateIntervalisCodable+Hashable, so synthesized conformances still hold.PlayaDBImpl.eventOccurrenceRequest(filter:)— whenactiveWindowis set, apply the overlap predicate (startTime < window.end && endTime > window.start), the same form asfetchEvents(from:to:).RightNowWorkflow.regionQuery— useactiveWindowinstead ofstartDate/endDate, with aguard floor < windowEndso an empty/past window can't form an invertedDateInterval. The region query now surfaces events already underway atfloor. 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
testEventOccurrenceRequestActiveWindowKeepsInProgressEventsdocuments both behaviors so the distinction can't silently regress: start-bounded filtering returns["in-window"], whileactiveWindowreturns["ongoing", "in-window"](keeping the in-progress event, excluding ended/future ones).Verification
FilterRequestBuilderTests: 15/15 pass🤖 Generated with Claude Code