fix(stats): restore worker runtime
This commit is contained in:
@@ -14,7 +14,6 @@ import {
|
|||||||
type StatsModelData,
|
type StatsModelData,
|
||||||
type UsageRange,
|
type UsageRange,
|
||||||
} from "@opencode-ai/stats-core/domain/home"
|
} from "@opencode-ai/stats-core/domain/home"
|
||||||
import { runtime } from "@opencode-ai/stats-core/runtime"
|
|
||||||
import { createAsync, query, useParams } from "@solidjs/router"
|
import { createAsync, query, useParams } from "@solidjs/router"
|
||||||
import { createMemo, createSignal, For, onMount, Show, type JSX } from "solid-js"
|
import { createMemo, createSignal, For, onMount, Show, type JSX } from "solid-js"
|
||||||
import { getRequestEvent } from "solid-js/web"
|
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) => {
|
const getModelData = query(async (lab: string, model: string) => {
|
||||||
"use server"
|
"use server"
|
||||||
return runtime.runPromise(getStatsModelData(model, lab))
|
const { statsRuntime } = await import("../../stats-runtime")
|
||||||
|
return statsRuntime.runPromise(getStatsModelData(model, lab))
|
||||||
}, "getStatsModelData")
|
}, "getStatsModelData")
|
||||||
|
|
||||||
export default function StatsModel() {
|
export default function StatsModel() {
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import {
|
|||||||
type ModelUsagePoint,
|
type ModelUsagePoint,
|
||||||
type StatsLabData,
|
type StatsLabData,
|
||||||
} from "@opencode-ai/stats-core/domain/home"
|
} from "@opencode-ai/stats-core/domain/home"
|
||||||
import { runtime } from "@opencode-ai/stats-core/runtime"
|
|
||||||
import { createAsync, query, useParams } from "@solidjs/router"
|
import { createAsync, query, useParams } from "@solidjs/router"
|
||||||
import { createMemo, createSignal, For, onMount, Show, type JSX } from "solid-js"
|
import { createMemo, createSignal, For, onMount, Show, type JSX } from "solid-js"
|
||||||
import { getRequestEvent } from "solid-js/web"
|
import { getRequestEvent } from "solid-js/web"
|
||||||
@@ -46,7 +45,8 @@ const labFooterLinks: readonly HeaderLink[] = [
|
|||||||
|
|
||||||
const getLabData = query(async (lab: string) => {
|
const getLabData = query(async (lab: string) => {
|
||||||
"use server"
|
"use server"
|
||||||
return runtime.runPromise(getStatsLabData(lab))
|
const { statsRuntime } = await import("../../stats-runtime")
|
||||||
|
return statsRuntime.runPromise(getStatsLabData(lab))
|
||||||
}, "getStatsLabData")
|
}, "getStatsLabData")
|
||||||
|
|
||||||
export default function StatsLab() {
|
export default function StatsLab() {
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import { AppConfig } from "@opencode-ai/stats-core/config"
|
import { AppConfig } from "@opencode-ai/stats-core/config"
|
||||||
import { runtime } from "@opencode-ai/stats-core/runtime"
|
|
||||||
import { Effect } from "effect"
|
import { Effect } from "effect"
|
||||||
|
|
||||||
export async function GET() {
|
export async function GET() {
|
||||||
|
const { statsRuntime } = await import("../../stats-runtime")
|
||||||
return Response.json(
|
return Response.json(
|
||||||
await runtime.runPromise(
|
await statsRuntime.runPromise(
|
||||||
Effect.gen(function* () {
|
Effect.gen(function* () {
|
||||||
const config = yield* AppConfig
|
const config = yield* AppConfig
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import {
|
|||||||
type TokenCostEntry,
|
type TokenCostEntry,
|
||||||
type UsagePoint,
|
type UsagePoint,
|
||||||
} from "@opencode-ai/stats-core/domain/home"
|
} from "@opencode-ai/stats-core/domain/home"
|
||||||
import { runtime } from "@opencode-ai/stats-core/runtime"
|
|
||||||
import { createAsync, query } from "@solidjs/router"
|
import { createAsync, query } from "@solidjs/router"
|
||||||
import { createEffect, createMemo, createSignal, For, onCleanup, onMount, Show, type JSX } from "solid-js"
|
import { createEffect, createMemo, createSignal, For, onCleanup, onMount, Show, type JSX } from "solid-js"
|
||||||
import { getRequestEvent } from "solid-js/web"
|
import { getRequestEvent } from "solid-js/web"
|
||||||
@@ -109,7 +108,8 @@ const worldBorderPath = worldPath(mesh(worldTopology, worldCountryGeometries, (a
|
|||||||
|
|
||||||
const getData = query(async () => {
|
const getData = query(async () => {
|
||||||
"use server"
|
"use server"
|
||||||
return runtime.runPromise(getStatsHomeData())
|
const { statsRuntime } = await import("../stats-runtime")
|
||||||
|
return statsRuntime.runPromise(getStatsHomeData())
|
||||||
}, "getStatsHomeData")
|
}, "getStatsHomeData")
|
||||||
|
|
||||||
export default function StatsHome() {
|
export default function StatsHome() {
|
||||||
|
|||||||
@@ -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))
|
||||||
Reference in New Issue
Block a user