mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-16 05:01:03 +03:00
fix(stats): include Go Plus usage (#58075)
This commit is contained in:
@@ -304,7 +304,7 @@ describe("inference stat normalization", () => {
|
||||
expect(queries[6]).toContain("'2026-08-12' AS period_key")
|
||||
expect(queries[0]).toContain('FROM "inference"."generation"')
|
||||
expect(queries[0]).toContain("event_type = 'generation.completed'")
|
||||
expect(queries[0]).toContain("AND (product = 'go' OR (lower(COALESCE(model_tier, '')) = 'free'")
|
||||
expect(queries[0]).toContain("AND (product IN ('go', 'go-plus') OR (lower(COALESCE(model_tier, '')) = 'free'")
|
||||
expect(queries[0]).toContain("COALESCE(NULLIF(lower(model_tier), ''), '') AS raw_tier")
|
||||
expect(queries[0]).toContain("WHEN lower(COALESCE(raw_tier, '')) = 'free'")
|
||||
expect(queries[0]).toContain("regexp_replace(NULLIF(route_model, ''), '^.*/', '')")
|
||||
@@ -362,7 +362,7 @@ describe("inference stat normalization", () => {
|
||||
expect(query).toContain("= 'deepseek-flash' THEN 'deepseek-v4.1-flash'")
|
||||
})
|
||||
expect(queries.map((query) => query.cohortDates)).toEqual([["2026-08-10"], ["2026-08-17"]])
|
||||
expect(queries[0]?.query).toContain("AND product = 'go'")
|
||||
expect(queries[0]?.query).toContain("AND product IN ('go', 'go-plus')")
|
||||
expect(queries[0]?.query).toContain("AND lower(model) NOT IN ('alpha-gpt-next')")
|
||||
expect(queries[0]?.query).toContain(
|
||||
"CASE\n WHEN lower(model) IN ('exo', 'omen-alpha', 'union-alpha') THEN 'unknown'\n",
|
||||
|
||||
@@ -41,6 +41,8 @@ const WEEK_MS = 7 * DAY_MS
|
||||
// boundary. Use one exclusive handoff so the overlapping rows are never counted
|
||||
// from both sources.
|
||||
const LIVE_SOURCE_START = "2026-08-11T10:57:48.186Z"
|
||||
// Go Plus is a level of the Go subscription, but the lake records it as its own product.
|
||||
const GO_PRODUCTS = ["go", "go-plus"]
|
||||
|
||||
// R2 SQL results are cursor-paginated after aggregation. Separate usage and geo
|
||||
// queries per day/week avoid combining costly distinct user/session aggregates
|
||||
@@ -135,7 +137,7 @@ WITH normalized AS (
|
||||
(source = 'inference-legacy' AND started_at < ${sqlString(LIVE_SOURCE_START)})
|
||||
OR (source = 'inference' AND started_at >= ${sqlString(LIVE_SOURCE_START)})
|
||||
)
|
||||
AND product = 'go'
|
||||
AND product IN (${GO_PRODUCTS.map(sqlString).join(", ")})
|
||||
AND model_requested IS NOT NULL
|
||||
AND model_requested <> ''
|
||||
AND __ingest_ts >= ${scanStartValue}
|
||||
@@ -299,7 +301,7 @@ WITH normalized AS (
|
||||
(source = 'inference-legacy' AND started_at < ${sqlString(LIVE_SOURCE_START)})
|
||||
OR (source = 'inference' AND started_at >= ${sqlString(LIVE_SOURCE_START)})
|
||||
)
|
||||
AND (product = 'go' OR (${sourceFreeTier}))
|
||||
AND (product IN (${GO_PRODUCTS.map(sqlString).join(", ")}) OR (${sourceFreeTier}))
|
||||
AND model_requested IS NOT NULL
|
||||
AND model_requested <> ''
|
||||
AND __ingest_ts >= ${periodStartValue}
|
||||
|
||||
Reference in New Issue
Block a user