fix(weight): delete removes the whole day's readings, not one duplicate#38
Merged
Conversation
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>
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.
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)), butDeleteWremoved only the targeted id —SelectWthen surfaced the next duplicate, so the value looked unchanged.Fix
DeleteW(id)now deletes every row sharing that id's date:Covers both
POST /wdel/andDELETE /api/weight/:id(both callDeleteW). 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 onInsertW.🤖 Generated with Claude Code