fix(stats): restore worker data exports
This commit is contained in:
parent
1a111be494
commit
c6f719e153
1 changed files with 21 additions and 18 deletions
|
|
@ -130,26 +130,28 @@ type ModelAggregate = {
|
||||||
totalCostMicrocents: number
|
totalCostMicrocents: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getStatsHomeData: () => Effect.Effect<
|
export function getStatsHomeData(): Effect.Effect<
|
||||||
StatsHomeData,
|
StatsHomeData,
|
||||||
DatabaseError,
|
DatabaseError,
|
||||||
ModelStatRepo | ProviderStatRepo | GeoStatRepo
|
ModelStatRepo | ProviderStatRepo | GeoStatRepo
|
||||||
> = Effect.fn("StatsHome.getData")(function* () {
|
> {
|
||||||
const modelStats = yield* ModelStatRepo
|
return Effect.gen(function* () {
|
||||||
const providerStats = yield* ProviderStatRepo
|
const modelStats = yield* ModelStatRepo
|
||||||
const geoStats = yield* GeoStatRepo
|
const providerStats = yield* ProviderStatRepo
|
||||||
const [modelRows, providerRows, geoRows] = yield* Effect.all(
|
const geoStats = yield* GeoStatRepo
|
||||||
[modelStats.listDaily(), providerStats.listDaily(), geoStats.listDaily()],
|
const [modelRows, providerRows, geoRows] = yield* Effect.all(
|
||||||
{ concurrency: "unbounded" },
|
[modelStats.listDaily(), providerStats.listDaily(), geoStats.listDaily()],
|
||||||
)
|
{ concurrency: "unbounded" },
|
||||||
return buildStatsHomeData(modelRows, providerRows, geoRows)
|
)
|
||||||
})
|
return buildStatsHomeData(modelRows, providerRows, geoRows)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
export const getStatsModelData: (
|
export function getStatsModelData(
|
||||||
model: string,
|
model: string,
|
||||||
provider?: string,
|
provider?: string,
|
||||||
) => Effect.Effect<StatsModelData | null, DatabaseError, ModelStatRepo | GeoStatRepo> = Effect.fn("StatsModel.getData")(
|
): Effect.Effect<StatsModelData | null, DatabaseError, ModelStatRepo | GeoStatRepo> {
|
||||||
function* (model, provider) {
|
return Effect.gen(function* () {
|
||||||
const modelStats = yield* ModelStatRepo
|
const modelStats = yield* ModelStatRepo
|
||||||
const geoStats = yield* GeoStatRepo
|
const geoStats = yield* GeoStatRepo
|
||||||
const modelRows = yield* modelStats.listDaily()
|
const modelRows = yield* modelStats.listDaily()
|
||||||
|
|
@ -165,14 +167,15 @@ export const getStatsModelData: (
|
||||||
}),
|
}),
|
||||||
provider,
|
provider,
|
||||||
)
|
)
|
||||||
},
|
})
|
||||||
)
|
}
|
||||||
|
|
||||||
export const getStatsLabData: (provider: string) => Effect.Effect<StatsLabData | null, DatabaseError, ModelStatRepo> =
|
export function getStatsLabData(provider: string): Effect.Effect<StatsLabData | null, DatabaseError, ModelStatRepo> {
|
||||||
Effect.fn("StatsLab.getData")(function* (provider) {
|
return Effect.gen(function* () {
|
||||||
const modelStats = yield* ModelStatRepo
|
const modelStats = yield* ModelStatRepo
|
||||||
return buildStatsLabData(provider, yield* modelStats.listDaily())
|
return buildStatsLabData(provider, yield* modelStats.listDaily())
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
function buildStatsHomeData(
|
function buildStatsHomeData(
|
||||||
modelRows: ModelStatMetric[],
|
modelRows: ModelStatMetric[],
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue