mirror of
https://github.com/anomalyco/opencode.git
synced 2026-05-31 13:31:39 +00:00
chore: generate
This commit is contained in:
parent
7504daa602
commit
425a4f584f
6 changed files with 40 additions and 75 deletions
|
|
@ -2,9 +2,7 @@
|
|||
"version": "6",
|
||||
"dialect": "mysql",
|
||||
"id": "c7296da3-649d-44f8-a6d5-7cbd755b2c67",
|
||||
"prevIds": [
|
||||
"e246639a-0da0-4fbd-b7bb-f1781d407780"
|
||||
],
|
||||
"prevIds": ["e246639a-0da0-4fbd-b7bb-f1781d407780"],
|
||||
"ddl": [
|
||||
{
|
||||
"name": "geo_stat",
|
||||
|
|
@ -1629,25 +1627,19 @@
|
|||
"table": "provider_stat"
|
||||
},
|
||||
{
|
||||
"columns": [
|
||||
"id"
|
||||
],
|
||||
"columns": ["id"],
|
||||
"name": "PRIMARY",
|
||||
"table": "geo_stat",
|
||||
"entityType": "pks"
|
||||
},
|
||||
{
|
||||
"columns": [
|
||||
"id"
|
||||
],
|
||||
"columns": ["id"],
|
||||
"name": "PRIMARY",
|
||||
"table": "model_stat",
|
||||
"entityType": "pks"
|
||||
},
|
||||
{
|
||||
"columns": [
|
||||
"id"
|
||||
],
|
||||
"columns": ["id"],
|
||||
"name": "PRIMARY",
|
||||
"table": "provider_stat",
|
||||
"entityType": "pks"
|
||||
|
|
@ -2102,4 +2094,4 @@
|
|||
}
|
||||
],
|
||||
"renames": []
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,9 +2,7 @@
|
|||
"version": "6",
|
||||
"dialect": "mysql",
|
||||
"id": "cefe97ad-34ad-42f3-9343-47b1b7f478fa",
|
||||
"prevIds": [
|
||||
"c7296da3-649d-44f8-a6d5-7cbd755b2c67"
|
||||
],
|
||||
"prevIds": ["c7296da3-649d-44f8-a6d5-7cbd755b2c67"],
|
||||
"ddl": [
|
||||
{
|
||||
"name": "geo_stat",
|
||||
|
|
@ -1671,25 +1669,19 @@
|
|||
"table": "provider_stat"
|
||||
},
|
||||
{
|
||||
"columns": [
|
||||
"id"
|
||||
],
|
||||
"columns": ["id"],
|
||||
"name": "PRIMARY",
|
||||
"table": "geo_stat",
|
||||
"entityType": "pks"
|
||||
},
|
||||
{
|
||||
"columns": [
|
||||
"id"
|
||||
],
|
||||
"columns": ["id"],
|
||||
"name": "PRIMARY",
|
||||
"table": "model_stat",
|
||||
"entityType": "pks"
|
||||
},
|
||||
{
|
||||
"columns": [
|
||||
"id"
|
||||
],
|
||||
"columns": ["id"],
|
||||
"name": "PRIMARY",
|
||||
"table": "provider_stat",
|
||||
"entityType": "pks"
|
||||
|
|
@ -2144,4 +2136,4 @@
|
|||
}
|
||||
],
|
||||
"renames": []
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,9 +2,7 @@
|
|||
"version": "6",
|
||||
"dialect": "mysql",
|
||||
"id": "9d4d1a06-7d28-4cb4-b0cd-3dfb7b481b8b",
|
||||
"prevIds": [
|
||||
"cefe97ad-34ad-42f3-9343-47b1b7f478fa"
|
||||
],
|
||||
"prevIds": ["cefe97ad-34ad-42f3-9343-47b1b7f478fa"],
|
||||
"ddl": [
|
||||
{
|
||||
"name": "geo_stat",
|
||||
|
|
@ -1587,25 +1585,19 @@
|
|||
"table": "provider_stat"
|
||||
},
|
||||
{
|
||||
"columns": [
|
||||
"id"
|
||||
],
|
||||
"columns": ["id"],
|
||||
"name": "PRIMARY",
|
||||
"table": "geo_stat",
|
||||
"entityType": "pks"
|
||||
},
|
||||
{
|
||||
"columns": [
|
||||
"id"
|
||||
],
|
||||
"columns": ["id"],
|
||||
"name": "PRIMARY",
|
||||
"table": "model_stat",
|
||||
"entityType": "pks"
|
||||
},
|
||||
{
|
||||
"columns": [
|
||||
"id"
|
||||
],
|
||||
"columns": ["id"],
|
||||
"name": "PRIMARY",
|
||||
"table": "provider_stat",
|
||||
"entityType": "pks"
|
||||
|
|
@ -2060,4 +2052,4 @@
|
|||
}
|
||||
],
|
||||
"renames": []
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,12 @@ import {
|
|||
} from "./stat"
|
||||
|
||||
export type GeoStatRow = typeof geoStat.$inferInsert
|
||||
export type GeoStatAggregate = StatBaseAggregate & { provider: string; model: string; country: string; continent: string }
|
||||
export type GeoStatAggregate = StatBaseAggregate & {
|
||||
provider: string
|
||||
model: string
|
||||
country: string
|
||||
continent: string
|
||||
}
|
||||
export type GeoStatMetric = {
|
||||
periodKey: string
|
||||
updatedAt: Date
|
||||
|
|
|
|||
|
|
@ -97,14 +97,7 @@ export function synthesizeAllTierRows<T extends StatBaseRow>(rows: T[], dimensio
|
|||
...rows,
|
||||
...Object.values(
|
||||
rows.reduce<Record<string, T>>((result, row) => {
|
||||
const key = [
|
||||
row.grain,
|
||||
row.period_key,
|
||||
row.dataset,
|
||||
row.client,
|
||||
row.source,
|
||||
dimensionKey(row),
|
||||
].join("\u0000")
|
||||
const key = [row.grain, row.period_key, row.dataset, row.client, row.source, dimensionKey(row)].join("\u0000")
|
||||
result[key] = result[key] ? combineRows(result[key], row) : { ...row, tier: "all" }
|
||||
return result
|
||||
}, {}),
|
||||
|
|
@ -115,15 +108,9 @@ export function synthesizeAllTierRows<T extends StatBaseRow>(rows: T[], dimensio
|
|||
export function collapseRows<T extends StatBaseRow>(rows: T[], dimensionKey: (row: T) => string) {
|
||||
return Object.values(
|
||||
rows.reduce<Record<string, T>>((result, row) => {
|
||||
const key = [
|
||||
row.grain,
|
||||
row.period_key,
|
||||
row.dataset,
|
||||
row.tier,
|
||||
row.client,
|
||||
row.source,
|
||||
dimensionKey(row),
|
||||
].join("\u0000")
|
||||
const key = [row.grain, row.period_key, row.dataset, row.tier, row.client, row.source, dimensionKey(row)].join(
|
||||
"\u0000",
|
||||
)
|
||||
result[key] = result[key] ? combineRows(result[key], row) : row
|
||||
return result
|
||||
}, {}),
|
||||
|
|
@ -170,7 +157,9 @@ export function startOfUtcDay(value: Date) {
|
|||
}
|
||||
|
||||
export function startOfIsoWeek(value: Date) {
|
||||
return new Date(Date.UTC(value.getUTCFullYear(), value.getUTCMonth(), value.getUTCDate() - (value.getUTCDay() || 7) + 1))
|
||||
return new Date(
|
||||
Date.UTC(value.getUTCFullYear(), value.getUTCMonth(), value.getUTCDate() - (value.getUTCDay() || 7) + 1),
|
||||
)
|
||||
}
|
||||
|
||||
export function isoWeekId(value: Date) {
|
||||
|
|
@ -188,7 +177,10 @@ export function rankBy<T extends StatBaseRow>(rows: T[], value: (row: T) => numb
|
|||
return new Map(rows.toSorted((a, b) => value(b) - value(a)).map((row, index) => [row, index + 1]))
|
||||
}
|
||||
|
||||
export function rankRowsWithMarketShare<T extends StatBaseRow>(rows: T[], groupKey: (row: T) => string = statPeriodKey) {
|
||||
export function rankRowsWithMarketShare<T extends StatBaseRow>(
|
||||
rows: T[],
|
||||
groupKey: (row: T) => string = statPeriodKey,
|
||||
) {
|
||||
return Object.values(
|
||||
rows.reduce<Record<string, T[]>>((result, row) => {
|
||||
const key = groupKey(row)
|
||||
|
|
|
|||
|
|
@ -192,11 +192,7 @@ function buildQueries(limit: number, tiers: string[]): QuerySpec[] {
|
|||
tier,
|
||||
metricQuery(["date", "tier", "stat_provider", "stat_model"], limit, tierFilters(tier)),
|
||||
),
|
||||
querySpec(
|
||||
"provider-day",
|
||||
tier,
|
||||
metricQuery(["date", "tier", "stat_provider"], limit, tierFilters(tier)),
|
||||
),
|
||||
querySpec("provider-day", tier, metricQuery(["date", "tier", "stat_provider"], limit, tierFilters(tier))),
|
||||
querySpec("geo-day", tier, metricQuery(["date", "tier", "country", "continent"], limit, tierFilters(tier))),
|
||||
querySpec(
|
||||
"geo-model-day",
|
||||
|
|
@ -205,7 +201,11 @@ function buildQueries(limit: number, tiers: string[]): QuerySpec[] {
|
|||
),
|
||||
])
|
||||
const weekly = tiers.flatMap((tier) => [
|
||||
querySpec("model-week", tier, metricQuery(["week", "tier", "stat_provider", "stat_model"], limit, tierFilters(tier))),
|
||||
querySpec(
|
||||
"model-week",
|
||||
tier,
|
||||
metricQuery(["week", "tier", "stat_provider", "stat_model"], limit, tierFilters(tier)),
|
||||
),
|
||||
querySpec("provider-week", tier, metricQuery(["week", "tier", "stat_provider"], limit, tierFilters(tier))),
|
||||
querySpec("geo-week", tier, metricQuery(["week", "tier", "country", "continent"], limit, tierFilters(tier))),
|
||||
querySpec(
|
||||
|
|
@ -227,11 +227,7 @@ function querySpec(importKey: ImportKey, tier: string, query: ReturnType<typeof
|
|||
}
|
||||
}
|
||||
|
||||
function metricQuery(
|
||||
breakdowns: string[],
|
||||
limit: number,
|
||||
filters: ReturnType<typeof commonFilters> = [],
|
||||
) {
|
||||
function metricQuery(breakdowns: string[], limit: number, filters: ReturnType<typeof commonFilters> = []) {
|
||||
return {
|
||||
granularity: 0,
|
||||
breakdowns,
|
||||
|
|
@ -409,11 +405,7 @@ function geoContinentLookup(row: RawRow, grain: Grain, opts: ImportOptions): [st
|
|||
return [[lookupKey({ ...base, dataset: opts.dataset, tier: tier(row), grain }, country(row)), value]]
|
||||
}
|
||||
|
||||
function geoModelAggregate(
|
||||
row: RawRow,
|
||||
base: StatBaseAggregate,
|
||||
continentLookup: Map<string, string>,
|
||||
): GeoAggregate[] {
|
||||
function geoModelAggregate(row: RawRow, base: StatBaseAggregate, continentLookup: Map<string, string>): GeoAggregate[] {
|
||||
const author = provider(row)
|
||||
if (!author) return []
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue