mirror of
https://github.com/anomalyco/opencode.git
synced 2026-07-10 00:28:29 +00:00
fix(stats): restore worker runtime
This commit is contained in:
parent
418a9e4e66
commit
c0dc6e50a7
5 changed files with 20 additions and 8 deletions
|
|
@ -14,7 +14,6 @@ import {
|
|||
type StatsModelData,
|
||||
type UsageRange,
|
||||
} from "@opencode-ai/stats-core/domain/home"
|
||||
import { runtime } from "@opencode-ai/stats-core/runtime"
|
||||
import { createAsync, query, useParams } from "@solidjs/router"
|
||||
import { createMemo, createSignal, For, onMount, Show, type JSX } from "solid-js"
|
||||
import { getRequestEvent } from "solid-js/web"
|
||||
|
|
@ -96,7 +95,8 @@ const worldBorderPath = worldPath(mesh(worldTopology, worldCountryGeometries, (a
|
|||
|
||||
const getModelData = query(async (lab: string, model: string) => {
|
||||
"use server"
|
||||
return runtime.runPromise(getStatsModelData(model, lab))
|
||||
const { statsRuntime } = await import("../../stats-runtime")
|
||||
return statsRuntime.runPromise(getStatsModelData(model, lab))
|
||||
}, "getStatsModelData")
|
||||
|
||||
export default function StatsModel() {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ import {
|
|||
type ModelUsagePoint,
|
||||
type StatsLabData,
|
||||
} from "@opencode-ai/stats-core/domain/home"
|
||||
import { runtime } from "@opencode-ai/stats-core/runtime"
|
||||
import { createAsync, query, useParams } from "@solidjs/router"
|
||||
import { createMemo, createSignal, For, onMount, Show, type JSX } from "solid-js"
|
||||
import { getRequestEvent } from "solid-js/web"
|
||||
|
|
@ -46,7 +45,8 @@ const labFooterLinks: readonly HeaderLink[] = [
|
|||
|
||||
const getLabData = query(async (lab: string) => {
|
||||
"use server"
|
||||
return runtime.runPromise(getStatsLabData(lab))
|
||||
const { statsRuntime } = await import("../../stats-runtime")
|
||||
return statsRuntime.runPromise(getStatsLabData(lab))
|
||||
}, "getStatsLabData")
|
||||
|
||||
export default function StatsLab() {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
import { AppConfig } from "@opencode-ai/stats-core/config"
|
||||
import { runtime } from "@opencode-ai/stats-core/runtime"
|
||||
import { Effect } from "effect"
|
||||
|
||||
export async function GET() {
|
||||
const { statsRuntime } = await import("../../stats-runtime")
|
||||
return Response.json(
|
||||
await runtime.runPromise(
|
||||
await statsRuntime.runPromise(
|
||||
Effect.gen(function* () {
|
||||
const config = yield* AppConfig
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ import {
|
|||
type TokenCostEntry,
|
||||
type UsagePoint,
|
||||
} from "@opencode-ai/stats-core/domain/home"
|
||||
import { runtime } from "@opencode-ai/stats-core/runtime"
|
||||
import { createAsync, query } from "@solidjs/router"
|
||||
import { createEffect, createMemo, createSignal, For, onCleanup, onMount, Show, type JSX } from "solid-js"
|
||||
import { getRequestEvent } from "solid-js/web"
|
||||
|
|
@ -109,7 +108,8 @@ const worldBorderPath = worldPath(mesh(worldTopology, worldCountryGeometries, (a
|
|||
|
||||
const getData = query(async () => {
|
||||
"use server"
|
||||
return runtime.runPromise(getStatsHomeData())
|
||||
const { statsRuntime } = await import("../stats-runtime")
|
||||
return statsRuntime.runPromise(getStatsHomeData())
|
||||
}, "getStatsHomeData")
|
||||
|
||||
export default function StatsHome() {
|
||||
|
|
|
|||
12
packages/stats/app/src/stats-runtime.ts
Normal file
12
packages/stats/app/src/stats-runtime.ts
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
import { AppConfig } from "@opencode-ai/stats-core/config"
|
||||
import { layer } from "@opencode-ai/stats-core/database"
|
||||
import { GeoStatRepo } from "@opencode-ai/stats-core/domain/geo"
|
||||
import { ModelStatRepo } from "@opencode-ai/stats-core/domain/model"
|
||||
import { ProviderStatRepo } from "@opencode-ai/stats-core/domain/provider"
|
||||
import { Layer, ManagedRuntime } from "effect"
|
||||
|
||||
const repoLayer = Layer.mergeAll(ModelStatRepo.layer, ProviderStatRepo.layer, GeoStatRepo.layer).pipe(
|
||||
Layer.provide(layer),
|
||||
)
|
||||
|
||||
export const statsRuntime = ManagedRuntime.make(Layer.mergeAll(AppConfig.layer, layer, repoLayer))
|
||||
Loading…
Add table
Add a link
Reference in a new issue