Files
sm-sitemap-plugin/jobs.go
Jakub Zych 653627b8c4 feat: real lastmod from record events and debounced rebuilds
- RecordSaved with a change outside golem15.sitemap.lastmod_ignore moves
  the lastmod of the record's rows (only the changed locale's for a
  translated change); a no-op save, an ignored change or a rebuild does not
- RecordDeleted takes the record's rows out of the files at once
- record events queue one rebuild per golem15.sitemap.rebuild_delay_seconds
  (rebuild_pending_until, P33-12); the job clears it when it starts
- sitemap:rebuild [--queue], scheduled nightly at 03:00 (pact.HasSchedule)
2026-11-04 11:17:28 +01:00

31 lines
919 B
Go

package sitemap
import (
"context"
"git.golem15.com/golem15/sm-sitemap-plugin/classes"
"git.golem15.com/golem15/summercms/modules/conga"
"git.golem15.com/golem15/summercms/modules/pact"
)
// Jobs registers the rebuild job (classes.RebuildKind) on conga.
func (p *Plugin) Jobs() []pact.Job {
return []pact.Job{
conga.Job(p.rebuild, conga.MaxAttempts(3)),
}
}
// rebuild runs one rebuild of the slot table. It ends the debounce window
// first, so record events during the rebuild queue the next one.
func (p *Plugin) rebuild(ctx context.Context, _ classes.RebuildArgs) error {
if err := classes.ClearPending(ctx, p.app); err != nil {
return err
}
res, err := classes.Rebuild(ctx, p.app)
if err != nil {
return err
}
pluginLog.Info("golem15.sitemap: rebuilt", "listed", res.Listed, "files", res.Files, "added", len(res.Added), "changed", len(res.Changed), "removed", len(res.Removed))
return nil
}