CI/CD Pipeline / build-push (ljwx-admin) (push) Blocked by required conditions
CI/CD Pipeline / build-push (ljwx-bigscreen) (push) Blocked by required conditions
CI/CD Pipeline / build-push (ljwx-boot) (push) Blocked by required conditions
CI/CD Pipeline / update-deploy (push) Blocked by required conditions
CI/CD Pipeline / security-scan (push) Successful in 54s
CI/CD Pipeline / test-build-boot (push) Successful in 5m15s
CI/CD Pipeline / build-pr (ljwx-admin) (push) Has been skipped
CI/CD Pipeline / build-pr (ljwx-bigscreen) (push) Has been skipped
CI/CD Pipeline / build-pr (ljwx-boot) (push) Has been skipped
CI/CD Pipeline / test-admin (push) Successful in 7m16s
CI/CD Pipeline / test-bigscreen (push) Failing after 29m38s
## 主要变更 ### 1. API 架构分析文档 - 创建 api-architecture-analysis.md:深度分析当前 API 架构混乱问题 - 发现核心问题:93% API 无版本号,命名规范混乱,功能重复 - 提供渐进式和激进式两种重构方案 ### 2. OpenAPI 契约维护文档 - 创建 openapi-maintenance-workflow.md:OpenAPI 维护流程规范 - 创建 v1-api-contract-validation.md:V1 API 契约验证报告 - 创建 v1-api-quick-reference.md:V1 API 快速参考指南 ### 3. ljwx-bigscreen API 迁移 - 修复 BigscreenApiV1Controller 中 userId 参数 required 问题 - 更新 ljwx-bigscreen 调用正确的 API 路径 - 修复 session key 不一致问题(customer_id vs customerId) - 添加 boot_api_client 统一 HTTP 客户端 ### 4. 日志和配置优化 - 添加 StaticFileFilter 过滤 304 日志 - 修复 SQLAlchemy ROLLBACK 警告 - 优化 ljwx-bigscreen 日志格式 ### 5. 数据库迁移 - 添加 V1.9.0 Flyway 迁移脚本(geofence alert 字段) - 创建本地数据库迁移指南 ### 6. Claude Code 配置 - 添加 context-guard.md 和 task-type-detector.md - 创建 QUICK_REFERENCE.md 决策流程图 - 优化 CLAUDE.md 文档管理规范 ## 下一步 - 启动激进式 API 重构 - 统一 ljwx-admin、ljwx-watch、ljwx-phone API - 维护 OpenAPI 契约 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
174 lines
6.3 KiB
YAML
174 lines
6.3 KiB
YAML
{{- if and .Values.clickhouse.enabled .Values.initJobs.clickhouse.enabled }}
|
|
apiVersion: batch/v1
|
|
kind: Job
|
|
metadata:
|
|
name: clickhouse-init-{{ .Release.Revision | default 1 }}
|
|
namespace: {{ .Values.global.namespace }}
|
|
labels:
|
|
app: clickhouse
|
|
component: init-job
|
|
annotations:
|
|
# Argo CD钩子
|
|
argocd.argoproj.io/hook: PostSync
|
|
argocd.argoproj.io/sync-wave: "2"
|
|
# Helm钩子
|
|
"helm.sh/hook": post-install,post-upgrade
|
|
"helm.sh/hook-weight": "2"
|
|
"helm.sh/hook-delete-policy": before-hook-creation
|
|
spec:
|
|
ttlSecondsAfterFinished: 300
|
|
backoffLimit: 5
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app: clickhouse
|
|
component: init-job
|
|
spec:
|
|
restartPolicy: Never
|
|
containers:
|
|
- name: init-tables
|
|
image: "{{ .Values.initJobs.clickhouse.image.repository }}:{{ .Values.initJobs.clickhouse.image.tag }}"
|
|
imagePullPolicy: {{ .Values.global.imagePullPolicy }}
|
|
command:
|
|
- sh
|
|
- -c
|
|
- |
|
|
set -e
|
|
|
|
echo "Waiting for ClickHouse to be ready..."
|
|
sleep 45
|
|
|
|
HOST="clickhouse.{{ .Values.global.namespace }}.svc.cluster.local"
|
|
PORT="{{ .Values.clickhouse.service.native.port }}" # ✅ Use native protocol port (9000) for clickhouse-client
|
|
|
|
echo "Initializing ClickHouse tables at ${HOST}:${PORT}..."
|
|
|
|
cat <<'EOF' | clickhouse-client \
|
|
--host ${HOST} \
|
|
--port ${PORT} \
|
|
--user ${CLICKHOUSE_USER} \
|
|
--password ${CLICKHOUSE_PASSWORD} \
|
|
--multiquery
|
|
|
|
-- 创建数据库
|
|
CREATE DATABASE IF NOT EXISTS ljwx_health;
|
|
|
|
-- 明细表
|
|
CREATE TABLE IF NOT EXISTS ljwx_health.t_health_raw (
|
|
event_id String,
|
|
org_id UInt32,
|
|
user_id UInt64,
|
|
device_sn String,
|
|
ts DateTime,
|
|
received_at DateTime DEFAULT now(),
|
|
heart_rate UInt16,
|
|
blood_oxygen UInt8,
|
|
temperature Float32,
|
|
pressure_high UInt16,
|
|
pressure_low UInt16,
|
|
stress UInt8,
|
|
step UInt32,
|
|
distance Float32,
|
|
calorie Float32,
|
|
version UInt8 DEFAULT 1
|
|
) ENGINE = ReplacingMergeTree(received_at)
|
|
PARTITION BY toYYYYMMDD(ts)
|
|
ORDER BY (org_id, user_id, ts)
|
|
TTL ts + INTERVAL 180 DAY
|
|
SETTINGS index_granularity = 8192;
|
|
|
|
-- 1分钟聚合表
|
|
CREATE TABLE IF NOT EXISTS ljwx_health.t_health_1min (
|
|
org_id UInt32,
|
|
user_id UInt64,
|
|
ts_minute DateTime,
|
|
heart_rate_avg Float32,
|
|
heart_rate_min UInt16,
|
|
heart_rate_max UInt16,
|
|
blood_oxygen_avg Float32,
|
|
blood_oxygen_min UInt8,
|
|
blood_oxygen_max UInt8,
|
|
temperature_avg Float32,
|
|
temperature_min Float32,
|
|
temperature_max Float32,
|
|
pressure_high_avg Float32,
|
|
pressure_low_avg Float32,
|
|
step_sum UInt64,
|
|
distance_sum Float32,
|
|
calorie_sum Float32,
|
|
record_count UInt32
|
|
) ENGINE = SummingMergeTree()
|
|
PARTITION BY toYYYYMM(ts_minute)
|
|
ORDER BY (org_id, user_id, ts_minute)
|
|
TTL ts_minute + INTERVAL 180 DAY
|
|
SETTINGS index_granularity = 8192;
|
|
|
|
-- 5分钟聚合表
|
|
CREATE TABLE IF NOT EXISTS ljwx_health.t_health_5min (
|
|
org_id UInt32,
|
|
user_id UInt64,
|
|
ts_5min DateTime,
|
|
heart_rate_avg Float32,
|
|
heart_rate_min UInt16,
|
|
heart_rate_max UInt16,
|
|
heart_rate_std Float32,
|
|
blood_oxygen_avg Float32,
|
|
blood_oxygen_min UInt8,
|
|
blood_oxygen_max UInt8,
|
|
temperature_avg Float32,
|
|
temperature_min Float32,
|
|
temperature_max Float32,
|
|
pressure_high_avg Float32,
|
|
pressure_low_avg Float32,
|
|
step_sum UInt64,
|
|
distance_sum Float32,
|
|
calorie_sum Float32,
|
|
record_count UInt32
|
|
) ENGINE = SummingMergeTree()
|
|
PARTITION BY toYYYYMM(ts_5min)
|
|
ORDER BY (org_id, user_id, ts_5min)
|
|
TTL ts_5min + INTERVAL 365 DAY
|
|
SETTINGS index_granularity = 8192;
|
|
|
|
-- 告警事件表
|
|
CREATE TABLE IF NOT EXISTS ljwx_health.t_alert_events (
|
|
alert_id String,
|
|
org_id UInt32,
|
|
user_id UInt64,
|
|
device_sn String,
|
|
alert_type String,
|
|
severity Enum8('low'=1, 'medium'=2, 'high'=3, 'critical'=4),
|
|
metric_name String,
|
|
metric_value Float32,
|
|
threshold_value Float32,
|
|
trigger_time DateTime,
|
|
resolved_time Nullable(DateTime),
|
|
status Enum8('active'=1, 'resolved'=2, 'acknowledged'=3) DEFAULT 'active',
|
|
notified UInt8 DEFAULT 0,
|
|
notification_channels Array(String)
|
|
) ENGINE = MergeTree()
|
|
PARTITION BY toYYYYMM(trigger_time)
|
|
ORDER BY (org_id, user_id, trigger_time)
|
|
TTL trigger_time + INTERVAL 365 DAY
|
|
SETTINGS index_granularity = 8192;
|
|
|
|
-- 验证
|
|
SELECT 'Tables initialized successfully!' as status;
|
|
SHOW TABLES FROM ljwx_health;
|
|
EOF
|
|
|
|
echo "ClickHouse initialization completed successfully!"
|
|
|
|
env:
|
|
- name: CLICKHOUSE_USER
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: clickhouse-secret
|
|
key: username
|
|
- name: CLICKHOUSE_PASSWORD
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: clickhouse-secret
|
|
key: password
|
|
{{- end }}
|