feat: contract.Rebuilder asks for a debounced rebuild

The sitemap publishes classes.Listing as contract.Rebuilder too, so a
plugin whose Filter reads data of its own can queue the debounced rebuild
a record event queues when that data changes.
This commit is contained in:
Jakub Zych
2026-11-04 22:39:14 +01:00
parent 1048c01fd9
commit 6b67ab759b
5 changed files with 59 additions and 5 deletions

View File

@@ -20,7 +20,10 @@ type Listing struct {
App *backpack.App
}
var _ contract.Listing = Listing{}
var (
_ contract.Listing = Listing{}
_ contract.Rebuilder = Listing{}
)
// The page sizes of Entries.
const (
@@ -39,6 +42,17 @@ func (l Listing) db(ctx context.Context) (*gorm.DB, error) {
return db.WithContext(ctx), nil
}
// RequestRebuild queues one debounced rebuild through
// RequestDebouncedRebuild, the same one a record event queues
// (contract.Rebuilder).
func (l Listing) RequestRebuild(ctx context.Context) error {
db, err := l.db(ctx)
if err != nil {
return err
}
return RequestDebouncedRebuild(ctx, l.App, db)
}
// Settings answers the site address, the index address, the default
// locale and the groups with listed addresses (by key), with their titles
// (a content type's saved HTML sitemap headings, else the titles of the