feat(coderd/database): add dbrollup service to rollup insights (#12665)

Add `dbrollup` service that runs the `UpsertTemplateUsageStats` query
every 5 minutes, on the minute. This allows us to have fairly real-time
insights data when viewing "today".
This commit is contained in:
Mathias Fredriksson
2024-03-22 18:42:43 +02:00
committed by GitHub
parent 04f0510b09
commit 12e6fbf11e
7 changed files with 479 additions and 5 deletions
+1
View File
@@ -24,6 +24,7 @@ const (
// This is for cleaning up old, unused resources from the database that take up space.
func New(ctx context.Context, logger slog.Logger, db database.Store) io.Closer {
closed := make(chan struct{})
logger = logger.Named("dbpurge")
ctx, cancelFunc := context.WithCancel(ctx)
//nolint:gocritic // The system purges old db records without user input.