Skip to content

Commit 83dbf73

Browse files
authored
perf: don't calculate build times for deleted templates (#21072)
The metrics cache to calculate and expose build time metrics for templates currently calls `GetTemplates`, which returns all templates even if they are deleted. We can use the `GetTemplatesWithFilter` query to easily filter out deleted templates from the results, and thus not call `GetTemplateAverageBuildTime` for those deleted templates. Delete time for workspaces for non-deleted templates is still calculated. Signed-off-by: Callum Styan <callumstyan@gmail.com>
1 parent 0ab23ab commit 83dbf73

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

coderd/metricscache/metricscache.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@ func (c *Cache) refreshTemplateBuildTimes(ctx context.Context) error {
8787
//nolint:gocritic // This is a system service.
8888
ctx = dbauthz.AsSystemRestricted(ctx)
8989

90-
templates, err := c.database.GetTemplates(ctx)
90+
templates, err := c.database.GetTemplatesWithFilter(ctx, database.GetTemplatesWithFilterParams{
91+
Deleted: false,
92+
})
9193
if err != nil {
9294
return err
9395
}

0 commit comments

Comments
 (0)