Skip to content

Conversation

@bjorkert
Copy link
Contributor

What’s fixed
Nightscout override segments are now sanitised before they hit the graph layer, so they never overlap and are never shorter than 5 minutes.

Why it crashed before
I trimmed each segment while iterating newest → oldest.
That meant I sometimes pushed the segment’s end earlier than its start, giving negative (or zero-length) durations.
The graph code asserts that duration > 0, so the app crashed as soon as one of those bad dots was drawn.

How it’s solved
1. Sort overrides oldest → newest first.
2. For each segment, cap its end at (nextStart − 5 min).
3. Skip any segment that ends up < 5 min long.

The result is a clean, strictly sequential timeline, so the graph renders without blowing up.

@marionbarker
Copy link
Collaborator

Test

Use a URL (provided privately) to demonstrate the crash.

Use PR branch. It fixed the crash but the resultant gaps in the override plot, where overlaps were truncated, were large (5 min each). Modify this to be 1 minute instead. Add comments to make it clear where overlaps are being removed and short overrides are being skipped.

Copy link
Collaborator

@marionbarker marionbarker left a comment

Choose a reason for hiding this comment

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

Reviewed and tested. LGTM.

@marionbarker marionbarker merged commit 3cba25f into dev May 20, 2025
@marionbarker marionbarker deleted the override-crash-fix branch June 28, 2025 20:45
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.

3 participants