fix(stats): filter market share to go

This commit is contained in:
Adam 2026-06-05 18:28:28 -05:00
commit b36b85936d
No known key found for this signature in database
GPG key ID: 9CB48779AF150E75

View file

@ -194,7 +194,7 @@ function buildStatsHomeData(
leaderboard: createUsageProductRecord((product) =>
createRangeRecord((range) => buildLeaderboard(normalized, product, getWindow(range, earliest, latest))),
),
market: createRangeRecord((range) => buildMarketShare(providers, range, getWindow(range, earliest, latest))),
market: createRangeRecord((range) => buildMarketShare(providers, "Go", range, getWindow(range, earliest, latest))),
tokenCost: createTokenProductRecord((product) =>
buildTokenCost(normalized, product, getWindow("1W", earliest, latest)),
),
@ -378,9 +378,9 @@ function buildLeaderboard(rows: StatMetricRow[], product: UsageProduct, window:
}))
}
function buildMarketShare(rows: ProviderMetricRow[], range: UsageRange, window: DateWindow) {
function buildMarketShare(rows: ProviderMetricRow[], product: UsageProduct, range: UsageRange, window: DateWindow) {
return createBuckets(window, range).flatMap((bucket) => {
const total = aggregateByProvider(rowsForProduct(rows, "All Users", bucket.start, bucket.end)).toSorted(
const total = aggregateByProvider(rowsForProduct(rows, product, bucket.start, bucket.end)).toSorted(
(a, b) => b.tokens - a.tokens,
)
const totalTokens = total.reduce((sum, item) => sum + item.tokens, 0)