Skip to content

Include the final fractional second in local day ranges - #1693

Open
skyfallwastaken wants to merge 1 commit into
fix-project-duration-attributionfrom
fix-heartbeat-day-boundaries
Open

Include the final fractional second in local day ranges#1693
skyfallwastaken wants to merge 1 commit into
fix-project-duration-attributionfrom
fix-heartbeat-day-boundaries

Conversation

@skyfallwastaken

Copy link
Copy Markdown
Member

Summary of the problem

Today and custom date ranges truncated their upper boundary, losing heartbeats during the final fractional second of a day.

Describe your changes

Use an exclusive next-local-midnight boundary, including across daylight-saving changes. Preserve stored timestamps and deduplication identity; duration output remains in whole seconds.

Screenshots / Media

Not applicable: backend-only changes.

@greptile-apps

greptile-apps Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Updates local-day filtering to use the next local midnight as an exclusive upper boundary.

  • Includes heartbeats occurring during the final fractional second of a day.
  • Preserves correct calendar boundaries across daylight-saving transitions.
  • Removes the duplicate Heartbeat.today scope in favour of the shared concern.
  • Adds regression coverage for both spring and autumn DST transitions.

Confidence Score: 5/5

The PR appears safe to merge, with regression coverage for fractional-second boundaries and DST-aware local days.

No new issues were introduced since the previous review, and the full PR remains consistent with the repository requirements.

Important Files Changed

Filename Overview
app/models/concerns/time_range_filterable.rb Uses exclusive next-local-midnight boundaries for today and bounded custom date ranges.
app/models/heartbeat.rb Removes the duplicate today scope so the shared time-range concern owns the behaviour.
test/models/heartbeat_test.rb Verifies fractional-second inclusion and exclusive boundaries across both DST transitions.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Local calendar date] --> B[Beginning of local day]
  A --> C[Beginning of next local day]
  B --> D{Heartbeat timestamp}
  C --> D
  D -->|timestamp >= start and timestamp < next midnight| E[Included]
  D -->|otherwise| F[Excluded]
Loading

Reviews (2): Last reviewed commit: "Include the final second in local heartb..." | Re-trigger Greptile

Co-authored-by: Amp <amp@ampcode.com>
@skyfallwastaken
skyfallwastaken force-pushed the fix-heartbeat-day-boundaries branch from aa16405 to 2dd9c68 Compare September 6, 2026 13:16
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