feat(web): add public leaderboard provider race endpoint#4787
feat(web): add public leaderboard provider race endpoint#4787pedroheyerdahl wants to merge 3 commits into
Conversation
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Executive SummaryFull review of the current head (the branch's commit SHAs were rewritten since the prior review, so the previous incremental-diff base commit no longer exists in history); the public leaderboard provider race endpoint correctly maps unmapped/NULL Files Reviewed (2 files)
Previous Review Summaries (3 snapshots, latest commit aa9aee5)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit aa9aee5)Status: No Issues Found | Recommendation: Merge Executive SummaryThe previously flagged NULL-coercion issue in the provider race endpoint is now resolved by mapping unmapped Files Reviewed (1 file changed since last review)
Previous review (commit 3431d73)Status: 1 Issue Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
Files Reviewed (1 file changed since last review)
Fix these issues in Kilo Cloud Previous review (commit e1a74e2)Status: 1 Issue Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
Files Reviewed (2 files)
Reviewed by claude-sonnet-5 · Input: 32 · Output: 8K · Cached: 735.4K Review guidance: REVIEW.md from base branch |
Weekly token volume per model lab for the kilo.ai/leaderboard/race visualization. Grouped at week x model_provider_company x is_open_weights so one payload drives both the per-lab race and an open-weight vs proprietary toggle. Lab mapping comes from the dbt model_dim seed rather than being re-derived in SQL. Depends on the kilocode-dbt usage_daily backfill that adds is_open_weights.
Match the prior '52 complete weeks' behavior so the latest returned week is always complete (keeps the insights 'latest complete week' stat correct).
Map only explicit 'true'/'false' strings to a boolean and return null for NULL/unmapped models so the open/closed split isn't silently corrupted by model_dim mapping gaps. Also removes the string===boolean comparison that broke the typecheck (TS2367).
aa9aee5 to
c217b0a
Compare
Summary
Adds a public Snowflake-backed endpoint
GET /api/public/leaderboard-provider-racethat serves weekly token volume per model lab for the kilo.ai/leaderboard/race visualization. The race page currently hardcodes 53 weeks of data in the landing repo; this endpoint lets it load dynamically.The query groups
kilo_dw.dbt_prod.usage_dailyatweek × model_provider_company × is_open_weights(fixed start2025-07-01→ most recent complete day). One payload drives both the per-lab race and an open-weight vs proprietary toggle. The lab mapping (model_provider_company,is_open_weights) comes from the dbtmodel_dimseed rather than being re-derived in SQL — this is the same gap the Omni dashboard's CASE workaround was papering over.Follows the existing
createPublicSnowflakeReportpattern (Redis-cached 1h, CORS, Sentry) used byleaderboard-model-usageandleaderboard-model-provider-usage.Verification
oxlintclean on both changed files (0 errors)leaderboard-model-usage/route.ts;tsgoreports no errors on the new files (full-repo typecheck blocked locally by unbuilt workspace packages — pre-existing, unrelated)Visual Changes
N/A
Reviewer Notes
usage_daily.is_open_weights, added by kilocode-dbt PR feat(kiloclaw): controller, device pairing, and dashboard redesign #480 + its backfill (2026-07-25-backfill-is-open-weights.sql). That backfill must run before this endpoint returns data; until then the query errors and the endpoint returns 502 (cachednull).[{ weekStart: "YYYY-MM-DD", provider: string, isOpenWeights: boolean | null, tokens: number }].isOpenWeightsisnullfor unmapped models (is_open_weightsNULL inmodel_dim) so the client can distinguish "unknown" from a confirmed closed-weight lab; only explicit'true'/'false'become a boolean.is_open_weightsis per-model in dbt, so a lab like Alibaba appears in both open and closed rows; the client sums acrossisOpenWeightsfor the lab race and acrossproviderfor the open/closed view.model_provider_company = 'other'(unmapped models) is included so the client can bucket it; drop here if we'd rather exclude upstream.