MCPcopy Index your code
hub / github.com/coder/coder / UpsertTemplateUsageStats

Method UpsertTemplateUsageStats

coderd/database/querier.go:1428–1428  ·  view source on GitHub ↗

This query aggregates the workspace_agent_stats and workspace_app_stats data into a single table for efficient storage and querying. Half-hour buckets are used to store the data, and the minutes are summed for each user and template combination. The result is stored in the template_usage_stats table

(ctx context.Context)

Source from the content-addressed store, hash-verified

1426 // used to store the data, and the minutes are summed for each user and template
1427 // combination. The result is stored in the template_usage_stats table.
1428 UpsertTemplateUsageStats(ctx context.Context) error
1429 // UpsertUserAIProviderKey preserves the original id and created_at when the
1430 // user/provider pair already exists. On conflict, callers provide id and
1431 // created_at for the insert path only.

Callers 5

startMethod · 0.65
TestTemplateMethod · 0.65

Implementers 5

sqlQueriercoderd/database/db.go
queryMetricsStorecoderd/database/dbmetrics/querymetrics
queriercoderd/database/dbauthz/dbauthz.go
MockStorecoderd/database/dbmock/dbmock.go
MockStoreMockRecordercoderd/database/dbmock/dbmock.go

Calls

no outgoing calls

Tested by 2

TestTemplateMethod · 0.52