Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion coderd/metricscache/metricscache.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ func (c *Cache) refreshTemplateBuildTimes(ctx context.Context) error {
//nolint:gocritic // This is a system service.
ctx = dbauthz.AsSystemRestricted(ctx)

templates, err := c.database.GetTemplates(ctx)
templates, err := c.database.GetTemplatesWithFilter(ctx, database.GetTemplatesWithFilterParams{
Deleted: false,
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be good to modify the UI that exercises this code path to include a deleted template and verify it's not included.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to work as expected. I modified fetchTemplate in templates.go to also retrieve deleted templates. That function is used to populate the results for the Templates UI page. It takes a minute to update due to the timing intervals and processing, but once I'd built a workspace from a copy of an existing template + saw a build time for that copy template, I deleted the workspace and template copy.

We can see that the template is then still displayed in the Templates page but it's build time is Unknown, and if we click on that template we get an error since it's been deleted.

Screenshot 2025-12-03 at 3 49 29 PM Screenshot 2025-12-03 at 3 49 50 PM

if err != nil {
return err
}
Expand Down
Loading