check / check (push) Waiting to run
A database target's rotation setting (none, monthly, daily or hourly) puts the UTC period of each event's receive time in its archive file name, so each file holds exactly its period's events. It is on the new webhook page and both target forms, and shown in the target list. Renames move every one of a target's files and move them all back if one fails. The sweep prunes one file at a time under the target's lock and deletes a rotated file it leaves empty. Download opens one file at a time, oldest period first, finding each again under the target's current name. The target list names the current file and totals all of them. Model: opus-5-5
43 lines
1.2 KiB
Go
43 lines
1.2 KiB
Go
package handlers
|
|
|
|
const (
|
|
// archiveRotationNone is the archive rotation that keeps a
|
|
// database target's archive in one file. A stored empty rotation
|
|
// means the same.
|
|
archiveRotationNone = "none"
|
|
|
|
// tmplKeyArchiveRotationChoices is the template data key for the
|
|
// entries of a page's archive rotation select.
|
|
tmplKeyArchiveRotationChoices = "ArchiveRotationChoices"
|
|
)
|
|
|
|
// archiveRotationChoices lists the archive rotations offered by the
|
|
// new webhook page, the add target form and the target edit form.
|
|
func archiveRotationChoices() []archiveChoice {
|
|
return []archiveChoice{
|
|
{Value: archiveRotationNone, Label: archiveRotationNone},
|
|
{Value: "monthly", Label: "monthly"},
|
|
{Value: "daily", Label: "daily"},
|
|
{Value: "hourly", Label: "hourly"},
|
|
}
|
|
}
|
|
|
|
// archiveRotationOptions returns the choices with rotation selected;
|
|
// an empty rotation, or one that is not a choice, selects none. A
|
|
// stored rotation is always a choice: the forms refuse any other.
|
|
func archiveRotationOptions(rotation string) []archiveChoice {
|
|
options := archiveRotationChoices()
|
|
|
|
for i := range options {
|
|
if options[i].Value == rotation {
|
|
options[i].Selected = true
|
|
|
|
return options
|
|
}
|
|
}
|
|
|
|
options[0].Selected = true
|
|
|
|
return options
|
|
}
|