Drying out
This commit is contained in:
@@ -1,34 +1,17 @@
|
||||
# Investigation Plan: Bedtime Graph Issue
|
||||
# Plan: Fix Timezone issues in WakeupPlot
|
||||
|
||||
## Objective
|
||||
Investigate why the "Bedtime" graph shows unexpected times when a specific `bedtime_ref` is set.
|
||||
## Problem
|
||||
`WakeupPlot.tsx` uses an incorrect manual calculation for timezone offsets and a dubious `isLikelyOffset` heuristic. This causes incorrect time displays (e.g., subtracting the offset instead of adding it).
|
||||
|
||||
## Current Understanding
|
||||
- The `BedtimePlot.tsx` component displays a graph where the Y-axis (or values) are formatted using `formatMinutesAfter(value, bedtime_ref)`.
|
||||
- The data comes from the `/api/stats/wake-sleep-times` endpoint.
|
||||
- The backend calculates `bedtime_minutes` based on sessions that started on or before the `bedtime_ref`.
|
||||
## Goal
|
||||
Align `WakeupPlot.tsx` with `BedtimePlot.tsx` by using the existing `getLocalOffsetFromReference` utility to correctly apply client-side timezone adjustments.
|
||||
|
||||
## Investigation Steps
|
||||
## Steps
|
||||
1. **Modify `frontend/src/components/stats/WakeupPlot.tsx`**:
|
||||
- Remove the `isLikelyOffset` logic and manual offset calculations.
|
||||
- Use `getLocalOffsetFromReference(day.wakeup_minutes, wakeup_ref)` to calculate the correct local offset.
|
||||
2. **Verify**:
|
||||
- Ensure the component renders correctly with the new logic.
|
||||
|
||||
### Step 1: Analyze Backend Logic
|
||||
- [ ] Examine `get_wake_sleep_times` in `backend/app/routers/stats.py` to understand how `bedtime_minutes` is calculated.
|
||||
- [ ] Verify if the logic correctly identifies "bedtime" for various sleep session scenarios (e.g., sessions crossing midnight).
|
||||
- [ ] Identify potential edge cases where the `s.start_time.time() <= b_ref_time` condition might be problematic.
|
||||
|
||||
### Step 2: Analyze Frontend Logic
|
||||
- [ ] Examine `BedtimePlot.tsx` and `useStats.ts` to see how the data is consumed and formatted.
|
||||
- [ ] Understand how `formatMinutesAfter` interacts with the values returned by the backend.
|
||||
|
||||
### Step 3: Data Simulation & Verification
|
||||
- [ ] Create a set of test cases (mocked data) representing different sleep scenarios.
|
||||
- [ ] Manually calculate the expected `bedtime_minutes` for these scenarios using the current logic.
|
||||
- [ ] Compare with what the user reported to confirm the bug's nature.
|
||||
|
||||
### Step 4: Propose and Implement Fixes
|
||||
- [ ] Refine the backend logic to better represent "bedtime" if current logic is insufficient.
|
||||
- [ ] Ensure the frontend correctly displays the intended time.
|
||||
- [ ] Verify that changes do not break other parts of the stats page (e.g., Wakeup times).
|
||||
|
||||
## Future Tasks
|
||||
- [ ] Run tests to ensure correctness after implementation.
|
||||
- [ ] Finalize documentation/explanation of the fix.
|
||||
## Files to change
|
||||
- `frontend/src/components/stats/WakeupPlot.tsx`
|
||||
|
||||
Reference in New Issue
Block a user