feat: build Onyx SSR shell and plan hero with mock data
This commit is contained in:
1 parent
84c20992f9
commit
2db494fb10
34 files changed
+3197
-2
No files matched your search
@@ -0,0 +1,37 @@
|
||||
import { applyScenario, buildStaffing, planWeekStart } from '../../shared/staffing'
|
||||
import { planDrivers } from '../../shared/insights'
|
||||
import { SCENARIOS, STANDARDS } from '../../shared/types'
|
||||
import type { Scenario, Standard } from '../../shared/types'
|
||||
import { getMockForecast, mockContext, mockDemo } from '../utils/mock-data'
|
||||
|
||||
export default defineEventHandler((event) => {
|
||||
const query = getQuery(event)
|
||||
const sensor = String(query.sensor ?? 'hn-stadtgalerie-01')
|
||||
const scenario = String(query.scenario ?? 'base') as Scenario
|
||||
const standard = String(query.standard ?? 'standard') as Standard
|
||||
const forecast = getMockForecast(sensor)
|
||||
|
||||
if (!forecast) {
|
||||
throw createError({ statusCode: 404, statusMessage: `Unknown sensor: ${sensor}` })
|
||||
}
|
||||
if (!SCENARIOS.includes(scenario)) {
|
||||
throw createError({ statusCode: 400, statusMessage: `Invalid scenario: ${scenario}` })
|
||||
}
|
||||
if (!STANDARDS.includes(standard)) {
|
||||
throw createError({ statusCode: 400, statusMessage: `Invalid standard: ${standard}` })
|
||||
}
|
||||
|
||||
const weekStart = planWeekStart(mockDemo.now)
|
||||
const build = buildStaffing({
|
||||
sensor,
|
||||
scenario,
|
||||
standard,
|
||||
points: applyScenario(forecast.points, scenario),
|
||||
weekStart,
|
||||
data_version: forecast.data_version,
|
||||
model_version: forecast.model_version,
|
||||
context_version: forecast.context_version,
|
||||
})
|
||||
build.response.why = planDrivers(build.response, mockContext, weekStart, scenario)
|
||||
return build.response
|
||||
})
|
||||
Reference in new issue
Block a user