Răsfoiți Sursa

chore: generate

opencode-agent[bot] 1 lună în urmă
părinte
comite
7a9337da8a
1 a modificat fișierele cu 25 adăugiri și 17 ștergeri
  1. 25 17
      packages/stats/core/src/domain/home.ts

+ 25 - 17
packages/stats/core/src/domain/home.ts

@@ -144,7 +144,11 @@ type RawRow = Record<string, unknown>
 export function getStatsHomeData(): Effect.Effect<StatsHomeData, StatsDataError> {
 export function getStatsHomeData(): Effect.Effect<StatsHomeData, StatsDataError> {
   return Effect.tryPromise({
   return Effect.tryPromise({
     try: async () => {
     try: async () => {
-      const [modelRows, providerRows, geoRows] = await Promise.all([listModelDaily(), listProviderDaily(), listGeoDaily()])
+      const [modelRows, providerRows, geoRows] = await Promise.all([
+        listModelDaily(),
+        listProviderDaily(),
+        listGeoDaily(),
+      ])
       return buildStatsHomeData(modelRows, providerRows, geoRows)
       return buildStatsHomeData(modelRows, providerRows, geoRows)
     },
     },
     catch: (cause) => new StatsDataError(cause),
     catch: (cause) => new StatsDataError(cause),
@@ -183,10 +187,12 @@ export function getStatsLabData(provider: string): Effect.Effect<StatsLabData |
 }
 }
 
 
 async function listModelDaily(): Promise<ModelStatMetric[]> {
 async function listModelDaily(): Promise<ModelStatMetric[]> {
-  return (await queryRows(`select period_key, updated_at, tier, provider, model, sessions, unique_users, input_tokens,
+  return (
+    await queryRows(`select period_key, updated_at, tier, provider, model, sessions, unique_users, input_tokens,
     output_tokens, reasoning_tokens, cache_read_tokens, total_tokens, input_cost_microcents, output_cost_microcents,
     output_tokens, reasoning_tokens, cache_read_tokens, total_tokens, input_cost_microcents, output_cost_microcents,
     total_cost_microcents from model_stat where grain = 'day' and client = 'all' and source = 'all'
     total_cost_microcents from model_stat where grain = 'day' and client = 'all' and source = 'all'
-    and tier in ('Go', 'go') order by period_key`)).map((row) => ({
+    and tier in ('Go', 'go') order by period_key`)
+  ).map((row) => ({
     periodKey: stringValue(row.period_key),
     periodKey: stringValue(row.period_key),
     updatedAt: dateValue(row.updated_at),
     updatedAt: dateValue(row.updated_at),
     tier: stringValue(row.tier),
     tier: stringValue(row.tier),
@@ -206,16 +212,16 @@ async function listModelDaily(): Promise<ModelStatMetric[]> {
 }
 }
 
 
 async function listProviderDaily(): Promise<ProviderStatMetric[]> {
 async function listProviderDaily(): Promise<ProviderStatMetric[]> {
-  return (await queryRows(`select period_key, updated_at, tier, provider, total_tokens from provider_stat
-    where grain = 'day' and client = 'all' and source = 'all' and tier in ('Go', 'go') order by period_key`)).map(
-    (row) => ({
-      periodKey: stringValue(row.period_key),
-      updatedAt: dateValue(row.updated_at),
-      tier: stringValue(row.tier),
-      provider: stringValue(row.provider),
-      totalTokens: numberValue(row.total_tokens),
-    }),
-  )
+  return (
+    await queryRows(`select period_key, updated_at, tier, provider, total_tokens from provider_stat
+    where grain = 'day' and client = 'all' and source = 'all' and tier in ('Go', 'go') order by period_key`)
+  ).map((row) => ({
+    periodKey: stringValue(row.period_key),
+    updatedAt: dateValue(row.updated_at),
+    tier: stringValue(row.tier),
+    provider: stringValue(row.provider),
+    totalTokens: numberValue(row.total_tokens),
+  }))
 }
 }
 
 
 async function listGeoDaily(opts?: { provider?: string; model?: string }): Promise<GeoStatMetric[]> {
 async function listGeoDaily(opts?: { provider?: string; model?: string }): Promise<GeoStatMetric[]> {
@@ -226,11 +232,13 @@ async function listGeoDaily(opts?: { provider?: string; model?: string }): Promi
         ? "and model = ?"
         ? "and model = ?"
         : "and provider = 'all' and model = 'all'"
         : "and provider = 'all' and model = 'all'"
   const params = opts?.model && opts.provider ? [opts.provider, opts.model] : opts?.model ? [opts.model] : []
   const params = opts?.model && opts.provider ? [opts.provider, opts.model] : opts?.model ? [opts.model] : []
-  return (await queryRows(
-    `select period_key, updated_at, tier, provider, model, country, continent, total_tokens from geo_stat
+  return (
+    await queryRows(
+      `select period_key, updated_at, tier, provider, model, country, continent, total_tokens from geo_stat
     where grain = 'day' and client = 'all' and source = 'all' and tier in ('Go', 'go') ${scope} order by period_key`,
     where grain = 'day' and client = 'all' and source = 'all' and tier in ('Go', 'go') ${scope} order by period_key`,
-    params,
-  )).map((row) => ({
+      params,
+    )
+  ).map((row) => ({
     periodKey: stringValue(row.period_key),
     periodKey: stringValue(row.period_key),
     updatedAt: dateValue(row.updated_at),
     updatedAt: dateValue(row.updated_at),
     tier: stringValue(row.tier),
     tier: stringValue(row.tier),