feat: 实现 G5 room_status 状态更新时跳过空 IP,增加 IP 归一化逻辑,更新相关测试
This commit is contained in:
27
openspec/changes/2026-03-18-g5-ip-skip-empty/spec.md
Normal file
27
openspec/changes/2026-03-18-g5-ip-skip-empty/spec.md
Normal file
@@ -0,0 +1,27 @@
|
||||
# G5 room_status 空 IP 跳过写入
|
||||
|
||||
## 背景
|
||||
Kafka payload 中包含 `ip` 字段,但该字段可能为空。对于 `room_status_moment_g5`,当 `ip` 为空时,应直接跳过该次状态写入,避免更新 `ts_ms`,也避免写入不完整数据。
|
||||
|
||||
## 目标
|
||||
1. G5 `room_status_moment_g5` 写入时补充 `ip` 字段。
|
||||
2. 当 `ip` 为空或空白时,G5 直接跳过这条状态,不进入缓冲、不触发 upsert、不更新 `ts_ms`。
|
||||
3. G4 逻辑保持现状,不受 G5 空 IP 策略影响。
|
||||
4. 保持 `ip` 作为有效值时的正常 upsert 与字段合并。
|
||||
|
||||
## 变更范围
|
||||
- `src/processor/statusExtractor.js`
|
||||
- 规范化 `ip`,将空字符串/空白字符串视为 `null`
|
||||
- `src/db/statusBatchProcessor.js`
|
||||
- G5 目标在 `ip` 为空时直接跳过
|
||||
- `src/db/roomStatusManager.js`
|
||||
- 在 upsert 中增加 `ip` 写入与更新逻辑
|
||||
- `tests/status_extractor.test.js`
|
||||
- 增加 `ip` 归一化测试
|
||||
- `tests/status_batch_processor.test.js`
|
||||
- 增加 G5 空 `ip` 直接跳过测试
|
||||
|
||||
## 验收标准
|
||||
1. G5 表 `room_status_moment_g5` 的记录可写入 `ip` 字段。
|
||||
2. `ip` 为空的 G5 状态不产生任何数据库写入。
|
||||
3. 现有测试通过。
|
||||
16
openspec/changes/2026-03-18-g5-ip-skip-empty/summary.md
Normal file
16
openspec/changes/2026-03-18-g5-ip-skip-empty/summary.md
Normal file
@@ -0,0 +1,16 @@
|
||||
# 2026-03-18 G5 空 IP 跳过写入修正
|
||||
|
||||
## 结果
|
||||
已修正 room_status_moment_g5 的写入规则:
|
||||
- 现在会写入 `ip` 字段
|
||||
- `ip` 为空或空白时,G5 状态直接跳过,不更新 `ts_ms`
|
||||
- G4 逻辑不受影响
|
||||
|
||||
## 关键实现
|
||||
- `statusExtractor` 规范化 `ip`
|
||||
- `statusBatchProcessor` 对 G5 空 `ip` 直接丢弃
|
||||
- `roomStatusManager` 的 upsert 增加 `ip` 列
|
||||
|
||||
## 验证
|
||||
- 新增测试覆盖 `ip` 归一化与 G5 空 `ip` 跳过
|
||||
- 现有测试应保持通过
|
||||
Reference in New Issue
Block a user