Allow retention_days of 0 to mean retain forever (closes #79)
Some checks failed
check / check (push) Has been cancelled
Some checks failed
check / check (push) Has been cancelled
Rewrites retention_days=0 to the RetentionForeverDays sentinel (365 * 1000) in Webhook.BeforeSave, so the GORM column default cannot win the race. The reaper skips retain-forever webhooks before building any query. Also bounds the reaper's cutoff arithmetic: a time.Duration is int64 nanoseconds, so day counts above MaxFiniteRetentionDays (106751) overflowed and wrapped the cutoff into the future, where created_at < cutoff matched every row and the sweep deleted everything. parseRetentionDays now rejects finite values above the ceiling, and retentionCutoff saturates so rows written by older versions cannot reach it either. Views render RetentionLabel() rather than the raw sentinel.
This commit was merged in pull request #96.
This commit is contained in:
@@ -181,7 +181,7 @@
|
||||
|
||||
<!-- Info -->
|
||||
<div class="mt-4 text-sm text-gray-400">
|
||||
<p>Retention: {{.Webhook.RetentionDays}} days · Created: {{.Webhook.CreatedAt.Format "2006-01-02 15:04:05 UTC"}}</p>
|
||||
<p>Retention: {{.Webhook.RetentionLabel}} · Created: {{.Webhook.CreatedAt.Format "2006-01-02 15:04:05 UTC"}}</p>
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
@@ -28,7 +28,8 @@
|
||||
|
||||
<div class="form-group">
|
||||
<label for="retention_days" class="label">Retention (days)</label>
|
||||
<input type="number" id="retention_days" name="retention_days" value="{{.Webhook.RetentionDays}}" min="1" max="365" class="input">
|
||||
<input type="number" id="retention_days" name="retention_days" value="{{.Webhook.RetentionDays}}" min="0" class="input">
|
||||
<p class="text-xs text-gray-500 mt-1">Currently {{.Webhook.RetentionLabel}}. Enter 0 to retain events forever.</p>
|
||||
</div>
|
||||
|
||||
<div class="flex gap-3">
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
<p class="text-sm text-gray-500 mt-1">{{.Description}}</p>
|
||||
{{end}}
|
||||
</div>
|
||||
<span class="badge-info">{{.RetentionDays}}d retention</span>
|
||||
<span class="badge-info">Retention: {{.RetentionLabel}}</span>
|
||||
</div>
|
||||
<div class="flex gap-6 mt-4 text-sm text-gray-500">
|
||||
<span>{{.EntrypointCount}} entrypoint{{if ne .EntrypointCount 1}}s{{end}}</span>
|
||||
|
||||
@@ -18,18 +18,18 @@
|
||||
<input type="hidden" name="csrf_token" value="{{.CSRFToken}}">
|
||||
<div class="form-group">
|
||||
<label for="name" class="label">Name</label>
|
||||
<input type="text" id="name" name="name" required autofocus placeholder="My Webhook" class="input">
|
||||
<input type="text" id="name" name="name" value="{{.Name}}" required autofocus placeholder="My Webhook" class="input">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="description" class="label">Description</label>
|
||||
<textarea id="description" name="description" rows="3" placeholder="Optional description" class="input"></textarea>
|
||||
<textarea id="description" name="description" rows="3" placeholder="Optional description" class="input">{{.Description}}</textarea>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="retention_days" class="label">Retention (days)</label>
|
||||
<input type="number" id="retention_days" name="retention_days" value="30" min="1" max="365" class="input">
|
||||
<p class="text-xs text-gray-500 mt-1">How long to keep event data.</p>
|
||||
<input type="number" id="retention_days" name="retention_days" value="{{.DefaultRetentionDays}}" min="0" class="input">
|
||||
<p class="text-xs text-gray-500 mt-1">How long to keep event data. Enter 0 to retain events forever.</p>
|
||||
</div>
|
||||
|
||||
<div class="flex gap-3">
|
||||
|
||||
Reference in New Issue
Block a user