feat(report): P1c 온라인 KPI 누적기 (live_kpi) + 메트릭 소스 일반화
온라인 히스토리안 3계층 — 실시간 KPI를 history_1s에서 산출·캐싱. - 메트릭 소스 일반화: history_table | history_1s | history_1min_src | fast_record. history_1min_src = 연속집계 드롭인 호환뷰(bucket→recorded_at). - Hc900LiveKpiService: 매 15s 오늘(KST) 컬럼별 KPI(production/yield/energy/closure)를 history_1s에서 재계산해 live_kpi upsert. 재계산=러닝상태의 stateless 동등판(causal 동치, 크래시 복구 불필요). 컬럼 state(normal/idle/error) 산출. - live_kpi 테이블 + GET /api/report/live 조회 엔드포인트. - Report:LiveKpi config(Enabled/IntervalSeconds/Source). 검증: 라이브 live_kpi 28행(7컬럼×4KPI) 15s 갱신, /live 정상. 데모 sim은 totalizer가 평평해 값 0/idle(플러밍 정상, 실데이터면 실값). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -33,3 +33,13 @@ WITH NO DATA;
|
||||
SELECT add_continuous_aggregate_policy('hc900.history_1min',
|
||||
start_offset => INTERVAL '3 hours', end_offset => INTERVAL '10 minutes',
|
||||
schedule_interval => INTERVAL '5 minutes', if_not_exists => TRUE);
|
||||
|
||||
-- P1c: 메트릭엔진 드롭인 소스(bucket→recorded_at) + 온라인 KPI 누적 테이블
|
||||
CREATE OR REPLACE VIEW hc900.history_1min_src AS
|
||||
SELECT tagname, bucket AS recorded_at, value, controller_id FROM hc900.history_1min;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS hc900.live_kpi (
|
||||
column_id text NOT NULL, kpi text NOT NULL, window_start date NOT NULL,
|
||||
value double precision, unit text, state text, excluded_min int, status text,
|
||||
updated_at timestamptz NOT NULL DEFAULT now(),
|
||||
PRIMARY KEY (column_id, kpi, window_start));
|
||||
|
||||
Reference in New Issue
Block a user