Skip to content

fix(weight): delete removes the whole day's readings, not one duplicate#38

Merged
rwlove merged 1 commit into
mainfrom
fix/weight-delete-by-day
Jun 10, 2026
Merged

fix(weight): delete removes the whole day's readings, not one duplicate#38
rwlove merged 1 commit into
mainfrom
fix/weight-delete-by-day

Conversation

@rwlove

@rwlove rwlove commented Jun 10, 2026

Copy link
Copy Markdown
Owner

Problem

Deleting the weight entry for 2026-06-07 "did not work" — the value stayed.

Root cause: the bt-scale gateway burst-posts the same reading multiple times with no ingest dedup, so 2026-06-07 had 6 identical rows (ids 189–194, within 4 seconds). The log shows one row per date (SELECT DISTINCT ON (date)), but DeleteW removed only the targeted id — SelectW then surfaced the next duplicate, so the value looked unchanged.

Fix

DeleteW(id) now deletes every row sharing that id's date:

DELETE FROM weight WHERE date = (SELECT date FROM weight WHERE id = $1)

Covers both POST /wdel/ and DELETE /api/weight/:id (both call DeleteW). Matches the day-oriented log.

Verification

Live-data preview (prod dump → local PG → pump): POST /wdel/ for 2026-06-07 cleared all 6 rows; 2026-06-09 (3 rows) untouched; the day no longer appears in /api/weight.

No UI change → screenshots unaffected. No schema change.

Follow-up (separate)

Weight ingest has no dedup; the bt-scale keeps burst-creating duplicate rows (harmless now, but messy). Could add (date, weight) dedup on InsertW.

🤖 Generated with Claude Code

The body-weight log shows one row per date (SelectW uses DISTINCT ON (date)),
but a day can hold several raw rows — the bt-scale gateway burst-posts the same
reading several times (e.g. 6 rows for 2026-06-07 within 4 seconds) and there
is no ingest-side dedup. The old DeleteW removed a single id, so SelectW just
surfaced the next duplicate and the value appeared unchanged — "delete didn't
work."

DeleteW now removes every row sharing the targeted id's date, so the displayed
entry actually disappears. Verified against a live-data preview: deleting the
2026-06-07 entry cleared all 6 rows and left other days untouched.

No UI change (delete control unchanged), so screenshots are unaffected. No
schema change.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@rwlove rwlove merged commit fd6ae08 into main Jun 10, 2026
@rwlove rwlove deleted the fix/weight-delete-by-day branch June 10, 2026 15:49
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