MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / arrayDimStatement

Function arrayDimStatement

telemetry-worker/src/rollup.ts:181–188  ·  view source on GitHub ↗

* One dimension unnested from a JSON array prop — one row per element, so an index * of a TypeScript+Go repo counts once under each language. `json_each` over a path * the props do not have yields no rows, which is exactly the wanted behaviour for * events that omit the array.

(dim: string, path: string, events: readonly string[])

Source from the content-addressed store, hash-verified

179 * events that omit the array.
180 */
181function arrayDimStatement(dim: string, path: string, events: readonly string[]): string {
182 return `INSERT INTO daily_dim_counts (day, event, dim, value, count, machines)
183 SELECT e.day, e.event, '${dim}', CAST(j.value AS TEXT), count(*), count(DISTINCT e.machine_id)
184 FROM events e, json_each(e.props, '${path}') j
185 WHERE e.day = ? AND e.event IN (${quoted(events)}) AND j.value <> ''
186 GROUP BY e.day, e.event, j.value
187 ${DIM_CONFLICT}`;
188}
189
190/**
191 * Rebuilt from `machine_days`, not from `events`: that table is never purged, so this

Callers 1

rollup.tsFile · 0.85

Calls 1

quotedFunction · 0.70

Tested by

no test coverage detected