fix(stats): run worker effects directly
This commit is contained in:
parent
a0aee82be9
commit
1a111be494
@ -26,7 +26,7 @@ import {
|
||||
type ModelCatalogCost,
|
||||
type ModelCatalogEntry,
|
||||
} from "../model-catalog"
|
||||
import { statsRuntime } from "../../stats-runtime"
|
||||
import { runStatsEffect } from "../../stats-runtime"
|
||||
import {
|
||||
applyThemePreference,
|
||||
Footer,
|
||||
@ -96,7 +96,7 @@ const worldBorderPath = worldPath(mesh(worldTopology, worldCountryGeometries, (a
|
||||
|
||||
const getModelData = query(async (lab: string, model: string) => {
|
||||
"use server"
|
||||
return statsRuntime.runPromise(getStatsModelData(model, lab))
|
||||
return runStatsEffect(getStatsModelData(model, lab))
|
||||
}, "getStatsModelData")
|
||||
|
||||
export default function StatsModel() {
|
||||
|
||||
@ -16,7 +16,7 @@ import {
|
||||
type ModelCatalogEntry,
|
||||
type ModelCatalogLab,
|
||||
} from "../model-catalog"
|
||||
import { statsRuntime } from "../../stats-runtime"
|
||||
import { runStatsEffect } from "../../stats-runtime"
|
||||
import {
|
||||
applyThemePreference,
|
||||
Footer,
|
||||
@ -46,7 +46,7 @@ const labFooterLinks: readonly HeaderLink[] = [
|
||||
|
||||
const getLabData = query(async (lab: string) => {
|
||||
"use server"
|
||||
return statsRuntime.runPromise(getStatsLabData(lab))
|
||||
return runStatsEffect(getStatsLabData(lab))
|
||||
}, "getStatsLabData")
|
||||
|
||||
export default function StatsLab() {
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
import { AppConfig } from "@opencode-ai/stats-core/config"
|
||||
import { Effect } from "effect"
|
||||
import { statsRuntime } from "../../stats-runtime"
|
||||
import { runStatsEffect } from "../../stats-runtime"
|
||||
|
||||
export async function GET() {
|
||||
return Response.json(
|
||||
await statsRuntime.runPromise(
|
||||
await runStatsEffect(
|
||||
Effect.gen(function* () {
|
||||
const config = yield* AppConfig
|
||||
return {
|
||||
|
||||
@ -26,7 +26,7 @@ import { createEffect, createMemo, createSignal, For, onCleanup, onMount, Show,
|
||||
import { getRequestEvent } from "solid-js/web"
|
||||
import type { FeatureCollection, GeometryObject, GeoJsonProperties } from "geojson"
|
||||
import type { GeometryCollection, Topology } from "topojson-specification"
|
||||
import { statsRuntime } from "../stats-runtime"
|
||||
import { runStatsEffect } from "../stats-runtime"
|
||||
import { findModelCatalogEntry, getModelCatalog, type ModelCatalog } from "./model-catalog"
|
||||
import {
|
||||
applyThemePreference,
|
||||
@ -109,7 +109,7 @@ const worldBorderPath = worldPath(mesh(worldTopology, worldCountryGeometries, (a
|
||||
|
||||
const getData = query(async () => {
|
||||
"use server"
|
||||
return statsRuntime.runPromise(getStatsHomeData())
|
||||
return runStatsEffect(getStatsHomeData())
|
||||
}, "getStatsHomeData")
|
||||
|
||||
export default function StatsHome() {
|
||||
|
||||
@ -3,10 +3,14 @@ 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"
|
||||
import { Effect, Layer } from "effect"
|
||||
import type { Success } from "effect/Layer"
|
||||
|
||||
const repoLayer = Layer.mergeAll(ModelStatRepo.layer, ProviderStatRepo.layer, GeoStatRepo.layer).pipe(
|
||||
Layer.provide(layer),
|
||||
)
|
||||
const statsLayer = Layer.mergeAll(AppConfig.layer, layer, repoLayer)
|
||||
|
||||
export const statsRuntime = ManagedRuntime.make(Layer.mergeAll(AppConfig.layer, layer, repoLayer))
|
||||
export function runStatsEffect<A, E>(effect: Effect.Effect<A, E, Success<typeof statsLayer>>) {
|
||||
return Effect.runPromise(Effect.provide(effect, statsLayer))
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user