fix(stats): scope model pages to go
This commit is contained in:
parent
213ff3f2d7
commit
1e63e76192
@ -123,8 +123,8 @@ export default function StatsModel() {
|
||||
const modelTitle = createMemo(() => `${modelName()} Data`)
|
||||
const modelDescription = createMemo(() =>
|
||||
stats()
|
||||
? `${modelName()} usage, rank, token mix, cost, geo breakdown, and peer data across OpenCode.`
|
||||
: `${modelName()} model facts, limits, and OpenCode usage availability.`,
|
||||
? `${modelName()} usage, rank, token mix, cost, geo breakdown, and peer data across OpenCode Go.`
|
||||
: `${modelName()} model facts, limits, and OpenCode Go usage availability.`,
|
||||
)
|
||||
const modelUrl = createMemo(() =>
|
||||
new URL(
|
||||
@ -257,7 +257,7 @@ function ModelHero(props: { data: StatsModelData | null; catalog: ModelCatalogEn
|
||||
<Show
|
||||
when={props.data}
|
||||
fallback={
|
||||
<p>Model facts from the shared model index. OpenCode usage appears once this model has activity.</p>
|
||||
<p>Model facts from the shared model index. OpenCode Go usage appears once this model has activity.</p>
|
||||
}
|
||||
>
|
||||
{(data) => (
|
||||
@ -298,7 +298,7 @@ function ModelCatalogCallout(props: { catalog: ModelCatalogEntry | null }) {
|
||||
<div data-component="model-rank-panel">
|
||||
<span>Model Profile</span>
|
||||
<strong>{props.catalog?.releaseDate ? formatCatalogDate(props.catalog.releaseDate) : "Listed"}</strong>
|
||||
<p>No OpenCode usage in the current data window.</p>
|
||||
<p>No OpenCode Go usage in the current data window.</p>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@ -329,10 +329,10 @@ function CatalogDatum(props: { label: string; value: string }) {
|
||||
function ModelOverview(props: { data: StatsModelData | null }) {
|
||||
return (
|
||||
<section data-section="model-panel">
|
||||
<SectionTitle title="Overview" description="Recent tokens, sessions, and market position." />
|
||||
<SectionTitle title="Overview" description="Recent OpenCode Go tokens, sessions, and market position." />
|
||||
<Show
|
||||
when={props.data}
|
||||
fallback={<ModelEmptyState title="No usage summary" description="This model has no OpenCode usage rows yet." />}
|
||||
fallback={<ModelEmptyState title="No usage summary" description="This model has no OpenCode Go usage rows yet." />}
|
||||
>
|
||||
{(data) => (
|
||||
<div data-component="model-metric-grid">
|
||||
@ -367,7 +367,7 @@ function ModelUsageSection(props: { data: ModelUsagePoint[] }) {
|
||||
|
||||
return (
|
||||
<section id="usage" data-section="model-panel">
|
||||
<SectionTitle title="Usage" description="Daily token volume over the recent two-month window." />
|
||||
<SectionTitle title="Usage" description="Daily OpenCode Go token volume over the recent two-month window." />
|
||||
<Show
|
||||
when={props.data.some((item) => item.tokens > 0)}
|
||||
fallback={<ModelEmptyState title="No usage" description="No usage landed in the current window." />}
|
||||
@ -461,7 +461,7 @@ function ModelUsageSection(props: { data: ModelUsagePoint[] }) {
|
||||
function ModelEfficiencySection(props: { data: StatsModelData | null; catalog: ModelCatalogEntry | null }) {
|
||||
return (
|
||||
<section id="efficiency" data-section="model-panel">
|
||||
<SectionTitle title="Efficiency" description="Cost, cache behavior, and average session shape." />
|
||||
<SectionTitle title="Efficiency" description="Cost, cache behavior, and average OpenCode Go session shape." />
|
||||
<Show
|
||||
when={props.data}
|
||||
fallback={
|
||||
@ -521,10 +521,10 @@ function ModelGeoBreakdownSection(props: { data: Record<UsageRange, CountryEntry
|
||||
setActiveCountry(undefined)
|
||||
}}
|
||||
>
|
||||
<SectionTitle title="Geo Breakdown" description="Model tokens used by country." />
|
||||
<SectionTitle title="Geo Breakdown" description="OpenCode Go model tokens used by country." />
|
||||
<Show
|
||||
when={data().length > 0}
|
||||
fallback={<ModelEmptyState title="No geo data" description="No geo_stat rows matched this model." />}
|
||||
fallback={<ModelEmptyState title="No geo data" description="No OpenCode Go geo_stat rows matched this model." />}
|
||||
>
|
||||
<div data-component="geo-breakdown">
|
||||
<div data-slot="geo-map-panel">
|
||||
@ -684,7 +684,7 @@ function GeoCountryList(props: {
|
||||
function ModelPeersSection(props: { data: StatsModelData | null }) {
|
||||
return (
|
||||
<section id="peers" data-section="model-panel">
|
||||
<SectionTitle title="Peers" description="Nearby models by recent token volume." />
|
||||
<SectionTitle title="Peers" description="Nearby models by recent OpenCode Go token volume." />
|
||||
<Show
|
||||
when={props.data?.peers.length}
|
||||
fallback={<ModelEmptyState title="No peers" description="Peer rankings appear after usage lands." />}
|
||||
|
||||
@ -23,7 +23,6 @@ export type SessionCostEntry = { model: string; cost: number; tokens: number }
|
||||
export type CountryEntry = { country: string; continent: string; tokens: number; share: number; rank: number }
|
||||
export type ModelUsagePoint = { date: string; tokens: number; sessions: number; cost: number }
|
||||
export type ModelMixEntry = { label: string; tokens: number; share: number }
|
||||
export type ModelProductEntry = { product: string; tokens: number; sessions: number; share: number }
|
||||
export type ModelPeerEntry = {
|
||||
model: string
|
||||
provider: string
|
||||
@ -63,7 +62,6 @@ export type StatsModelData = {
|
||||
}
|
||||
usage: ModelUsagePoint[]
|
||||
tokenMix: ModelMixEntry[]
|
||||
productMix: ModelProductEntry[]
|
||||
country: Record<UsageRange, CountryEntry[]>
|
||||
peers: ModelPeerEntry[]
|
||||
}
|
||||
@ -286,7 +284,6 @@ function buildStatsModelData(
|
||||
},
|
||||
usage: buildModelUsage(currentRows, window, "2M"),
|
||||
tokenMix: buildModelTokenMix(current),
|
||||
productMix: buildModelProductMix(modelScopedRows, window, current),
|
||||
country: createRangeRecord((range) => buildCountryStats(geo, getWindow(range, earliest, latest))),
|
||||
peers: buildModelPeers(peers, peerRank, totalTokens),
|
||||
}
|
||||
@ -523,26 +520,6 @@ function buildModelTokenMix(aggregate: ModelAggregate): ModelMixEntry[] {
|
||||
return items.map((item) => ({ ...item, share: round((item.tokens / total) * 100, 1) }))
|
||||
}
|
||||
|
||||
function buildModelProductMix(
|
||||
rows: StatMetricRow[],
|
||||
window: DateWindow,
|
||||
fallback: ModelAggregate,
|
||||
): ModelProductEntry[] {
|
||||
const products = ["Go", "Zen", "Enterprise"] as const
|
||||
const items = products.flatMap((product) => {
|
||||
const aggregate = combineRowsForModel(
|
||||
fallback.model,
|
||||
rows.filter((row) => row.tier === product && row.periodStart >= window.start && row.periodStart < window.end),
|
||||
)
|
||||
if (aggregate.totalTokens === 0) return []
|
||||
return [{ product, tokens: aggregate.totalTokens, sessions: aggregate.sessions }]
|
||||
})
|
||||
const total = items.reduce((sum, item) => sum + item.tokens, 0)
|
||||
if (total > 0) return items.map((item) => ({ ...item, share: round((item.tokens / total) * 100, 1) }))
|
||||
if (fallback.totalTokens === 0) return []
|
||||
return [{ product: "All Users", tokens: fallback.totalTokens, sessions: fallback.sessions, share: 100 }]
|
||||
}
|
||||
|
||||
function buildModelPeers(peers: ModelAggregate[], rank: number, totalTokens: number): ModelPeerEntry[] {
|
||||
const start = Math.max(0, Math.min(rank - 4, Math.max(peers.length - 7, 0)))
|
||||
return peers.slice(start, start + 7).map((item, index) => ({
|
||||
|
||||
Loading…
Reference in New Issue
Block a user