Oura sync imports sleep score + readiness but never HRV or resting HR — likely the end_date exclusive quirk on Oura's detailed sleep endpoint

Connected Oura today on a brand-new account. The daily summary data backfilled beautifully - 56 days of sleep score and readiness going back to June 1. But `hrv` and `restingHR` are null on **every single one of those days**, including days where Oura definitely has the data.

My athlete settings look correct: `oura_scope` is `daily heartrate workout tag session spo2`, and `oura_wellness_keys` is `[‘sleep’, ‘restingHR’, ‘hrv’, ‘readiness’]`. So it’s asking for the right fields, and the backfill clearly isn’t shallow - it’s specifically the detailed sleep data that never arrives.

**What I think is happening.** Oura’s `/v2/usercollection/sleep` endpoint - the detailed one carrying `average_hrv` and `lowest_heart_rate` - appears to treat **`end_date` as exclusive**. A single-day query returns nothing at all:

`start_date=2026-07-28&end_date=2026-07-28` returns **0 records**.

`start_date=2026-07-28&end_date=2026-07-29` returns **2 records**, including `{“day”: “2026-07-28”, “type”: “long_sleep”, “average_hrv”: 25, “lowest_heart_rate”: 46}`.

Note that `/v2/usercollection/daily_sleep` (the summary endpoint) does **not** behave this way - which would explain exactly the pattern I’m seeing: scores import fine, detailed metrics silently come back empty.

I hit this identical bug in my own tooling and that was the cause, so I thought it was worth flagging in case the same single-day pattern is in your Oura importer.

**One more thing worth handling.** Oura returns **multiple sleep records per day** - `long_sleep`, `sleep`, `late_nap`, `rest`. On 2026-07-27 I get four records with HRV values of 33, 27 and 19. The 33 is a late nap; the actual night is the `long_sleep` record at 27. So padding the date range alone isn’t sufficient - if the first record wins, a nap’s HRV gets recorded as the night’s value. Suggest preferring `type == “long_sleep”`, falling back to the longest `total_sleep_duration`.

**Workaround for anyone else hitting this.** I backfilled 57 days by pulling Oura’s API directly with a padded range and writing to `PUT /athlete/{id}/wellness/{date}` with `hrv` and `restingHR`. Works fine - just noting it in case others want their history filled while this gets looked at.

Happy to test a fix or supply more detail. Great platform - the open API is the reason I chose it over the alternatives.