Store a webhook's retention as a plain day count, 0 meaning forever (closes #539) #546

Merged
clawbot merged 1 commits from issue-539-retention-day-count into next 2026-10-15 20:03:33 +02:00
Collaborator

Closes #539.

A webhook's retention_days is now stored exactly as entered, and 0 means its events are kept forever.

  • 001_schema.sql drops DEFAULT 30 on retention_days, and Webhook.RetentionDays drops its default:30 tag. Without them a 0 is stored as 0, so RetentionForeverDays (the 365000-day stand-in for forever) and the Webhook.BeforeSave hook that wrote it are gone.
  • retainsForever no longer knows a stand-in value; it reads 0 as forever. The reaper, the webhook page's event counts and the "forever" label all go through it.
  • parseRetentionDays accepts 0 or 1 to MaxFiniteRetentionDays and refuses anything else with the existing messages. A blank field still gives 30 on the new webhook form and keeps the stored value on the edit form, so the two handlers needed no change.
  • The edit form now pre-fills 0 for a webhook that keeps its events, which matches what its help text already said.
  • The README Webhook section is rewritten to match.

Tests cover blank, 0, a day count and a too-large value on the new webhook form, 0 surviving create and save, and the reaper keeping the events of a webhook set to 0.

Judgement call: retainsForever reads a negative value as forever too, not only 0. The forms refuse a negative value, but read as a day count it would put the reaper's cutoff in the future and delete every event, so it is read as forever, as it was before.

Model: opus-5-5

Closes https://git.eeqj.de/sneak/webhooker/issues/539. A webhook's `retention_days` is now stored exactly as entered, and `0` means its events are kept forever. - `001_schema.sql` drops `DEFAULT 30` on `retention_days`, and `Webhook.RetentionDays` drops its `default:30` tag. Without them a `0` is stored as `0`, so `RetentionForeverDays` (the 365000-day stand-in for forever) and the `Webhook.BeforeSave` hook that wrote it are gone. - `retainsForever` no longer knows a stand-in value; it reads `0` as forever. The reaper, the webhook page's event counts and the "forever" label all go through it. - `parseRetentionDays` accepts `0` or `1` to `MaxFiniteRetentionDays` and refuses anything else with the existing messages. A blank field still gives 30 on the new webhook form and keeps the stored value on the edit form, so the two handlers needed no change. - The edit form now pre-fills `0` for a webhook that keeps its events, which matches what its help text already said. - The README Webhook section is rewritten to match. Tests cover blank, `0`, a day count and a too-large value on the new webhook form, `0` surviving create and save, and the reaper keeping the events of a webhook set to `0`. Judgement call: `retainsForever` reads a negative value as forever too, not only `0`. The forms refuse a negative value, but read as a day count it would put the reaper's cutoff in the future and delete every event, so it is read as forever, as it was before. Model: opus-5-5
clawbot self-assigned this 2026-10-15 13:36:11 +02:00
clawbot added the needs-review label 2026-10-15 13:36:12 +02:00
Author
Collaborator

FAIL (needs-rework)

  1. internal/handlers/source_management_test.go, the comment above TestHandleSourceCreate_PrefillsDefaultFromConstant (lines 286 to 288): it says the test keeps the new webhook form's pre-filled retention from becoming "a third hardcoded copy of the 30-day policy". The two copies it counted were DefaultRetentionDays and the default:30 tag that this change removes, so DefaultRetentionDays is now the only one and the sentence no longer matches the code. Acceptable: the comment says what the test guards now, that the pre-filled value comes from database.DefaultRetentionDays rather than a hardcoded 30.

Judgement call: reading a negative stored value as forever is accepted, because read as a day count it would delete every event the webhook has.
Judgement call: leaving retention_days nullable is accepted; it matches the rest of the schema, every save writes a value, and a null reads as 0.

Model: opus-5-5

FAIL (needs-rework) 1. `internal/handlers/source_management_test.go`, the comment above `TestHandleSourceCreate_PrefillsDefaultFromConstant` (lines 286 to 288): it says the test keeps the new webhook form's pre-filled retention from becoming "a third hardcoded copy of the 30-day policy". The two copies it counted were `DefaultRetentionDays` and the `default:30` tag that this change removes, so `DefaultRetentionDays` is now the only one and the sentence no longer matches the code. Acceptable: the comment says what the test guards now, that the pre-filled value comes from `database.DefaultRetentionDays` rather than a hardcoded 30. Judgement call: reading a negative stored value as forever is accepted, because read as a day count it would delete every event the webhook has. Judgement call: leaving `retention_days` nullable is accepted; it matches the rest of the schema, every save writes a value, and a null reads as 0. Model: opus-5-5
clawbot added needs-rework and removed needs-review labels 2026-10-15 19:28:36 +02:00
clawbot added 1 commit 2026-10-15 19:41:29 +02:00
retention_days loses its column default of 30, and Webhook.RetentionDays
its default tag, so a 0 is stored as 0. The 365000-day stand-in
RetentionForeverDays and the BeforeSave hook that wrote it are gone. The
reaper and the "forever" label read 0 as forever, and the forms accept 0
or 1 to MaxFiniteRetentionDays; a blank field still gives 30 on the new
webhook form and keeps the stored value on the edit form. A negative
value, which the forms refuse, is still read as forever so it cannot put
the reaper's cutoff in the future.

Model: opus-5-5
clawbot force-pushed issue-539-retention-day-count from 7c273d2d19 to ec4679cd17 2026-10-15 19:41:29 +02:00 Compare
Author
Collaborator

The comment above TestHandleSourceCreate_PrefillsDefaultFromConstant now says the test checks that the new webhook form pre-fills its retention from database.DefaultRetentionDays rather than a hardcoded 30; no other comment or README sentence still counted the removed column default or the old 365000-day value.

Model: opus-5-5

The comment above `TestHandleSourceCreate_PrefillsDefaultFromConstant` now says the test checks that the new webhook form pre-fills its retention from `database.DefaultRetentionDays` rather than a hardcoded 30; no other comment or README sentence still counted the removed column default or the old 365000-day value. Model: opus-5-5
clawbot added needs-review and removed needs-rework labels 2026-10-15 19:53:58 +02:00
Author
Collaborator

PASS: a retention of 0 is now stored, kept by retention and shown as forever on every page and form; a blank field on the new webhook form gives 30; a value above database.MaxFiniteRetentionDays is refused with the existing message; and nothing of the old 365000-day value, the save hook or the column default remains, so #539 is done.

Model: opus-5-5

PASS: a retention of `0` is now stored, kept by retention and shown as forever on every page and form; a blank field on the new webhook form gives 30; a value above `database.MaxFiniteRetentionDays` is refused with the existing message; and nothing of the old 365000-day value, the save hook or the column default remains, so https://git.eeqj.de/sneak/webhooker/issues/539 is done. Model: opus-5-5
clawbot merged commit f10440b7cc into next 2026-10-15 20:03:33 +02:00
clawbot deleted branch issue-539-retention-day-count 2026-10-15 20:03:34 +02:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/webhooker#546