v1.37.24 — stop waiting for sleep that never comes - #801
Merged
Conversation
The hero card on the start page told anyone without a sleep source, every
morning, that last night's sleep was not in yet. The freshness rule only
asked whether last night's sleep had landed, so a record that has never had
a night in it, or whose owner has stopped wearing the tracker, read as
permanently waiting. Not everyone owns one, and people put them away.
Waiting now requires that sleep is actually reaching the record: a night
within the last seven days. A flat battery or a few nights without the
tracker keeps the note, since tonight's sleep really is still expected. A
week of silence retires it.
The same rule settles the day itself. It used to park on `provisional`
forever for those records, which the daily push line reads too, so the
notification carried the same untrue "last night's sleep is still missing"
aside.
Two existing tests pinned the old behaviour by name ("is provisional when
sleep has never been recorded", "stays provisional when sleep never
arrives"). They described the defect rather than a contract worth keeping,
so they now assert the opposite, and a third covers the boundary between an
ordinary gap and a source that has gone quiet.
The scenario purges every sleep row so last night can be the arrival that flips the day. That left an account with no sleep source at all, which now reads `final` on purpose, so the provisional assertion could not be reached. Seeding a night from three days ago restores what the scenario means: a record that does track sleep, waiting for last night's. Written through the same ingest route as the fresh night and swept by the same purge.
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.
The hero card on the start page told anyone without a sleep source, every morning, that last night's sleep was not in yet. The freshness rule asked only whether last night had landed, and
sleepLastSeenDaysAgois null when sleep has never been recorded, so a record with no tracker read as permanently waiting. Not everyone owns one, and people put them away.Waiting now requires that sleep actually reaches the record: a night within the last seven days. A flat battery or a few nights without the device keeps the note, because tonight's sleep really is still expected. A week of silence retires it.
The same rule settles the day itself. It used to park on
provisionalforever for those records, and the daily push line reads the same field, so the notification carried the identical untrue aside.Two existing tests pinned the old behaviour by name ("is provisional when sleep has never been recorded", "stays provisional when sleep never arrives"). They described the defect rather than a contract worth keeping, so they assert the opposite now, and a third covers the boundary between an ordinary gap (7 days, still waiting) and a source that has gone quiet (8 days, settled). Reverting
isSleepExpectedto the old always-true behaviour turns all three red.Gate: typecheck, lint, format:check, 1885 test files / 21446 tests, and
next buildall green locally.