While investigating a separate issue, @dannykopping noticed that the /api/v2/workspaceagents/:id handler has a bit of an N+1 query issue.
From the trace:
We can see a number of duplicated queries in the trace:
- GetWorkspaceByID
- GetWorkspaceBuildByJobID
- GetProvisionerJobByID
etc.
We should only need to call any of the given DB queries once per endpoint invocation.