feat(processor): 添加循环名称自动生成的配置开关

新增环境变量 ENABLE_LOOP_NAME_AUTO_GENERATION 用于控制当缓存未命中时是否自动生成循环名称。当设置为 false 时,系统将不再生成 [类型-地址-回路] 格式的备用名称,而是直接返回 null。更新了配置文件、处理器逻辑并添加了相应的单元测试。
This commit is contained in:
2026-02-03 09:26:01 +08:00
parent 4e0f5213db
commit 339db6f95f
9 changed files with 112 additions and 5 deletions

View File

@@ -1,6 +1,6 @@
# Feature: Loop Name Enrichment
**Status**: Proposed
**Status**: Implemented
**Date**: 2026-02-02
## Summary

View File

@@ -0,0 +1,22 @@
# Feature: Feature Toggle Loop Name Generation
**Status**: Implemented
**Date**: 2026-02-03
## Summary
Add a configuration switch to control the fallback behavior for `loop_name` generation. Currently, when cache lookup fails, the system auto-generates a name using the format `[Type-Addr-Loop]`. This change allows users to enable or disable this fallback behavior via an environment variable.
## Requirements
1. **Configuration**:
- Add `ENABLE_LOOP_NAME_AUTO_GENERATION` to environment variables.
- Default behavior should match existing logic (enable generation) if not specified, but user requested explicit control.
- If `true`: Perform concatenation `[dev_type名称+'-'+dev_addr+'-'+dev_loop]`.
- If `false`: Do not generate name, leave `loop_name` as null (or whatever default is appropriate, likely null).
2. **Processor Logic**:
- In `getLoopNameWithFallback`, check the configuration flag before applying the fallback generation logic.
## Implementation Plan
1. **Config**: Update `src/config/config.js` to parse `ENABLE_LOOP_NAME_AUTO_GENERATION`.
2. **Env**: Update `.env` and `.env.example`.
3. **Processor**: Update `src/processor/index.js` to respect the flag.

View File

@@ -0,0 +1,27 @@
# Summary of Changes: Loop Name Features
**Date**: 2026-02-03
**Status**: Archived
## Overview
This archive contains the specifications and proposals for the Loop Name Enrichment and Auto-Generation features. These features enhance the RCU Action Server by enriching event data with descriptive loop names derived from project metadata or fallback generation logic.
## Included Changes
### 1. [Feature: Loop Name Enrichment](./feature-loop-name-enrichment.md)
- **Goal**: Enrich `rcu_action_events` with `loop_name` by looking up cached metadata from `temporary_project` tables.
- **Key Components**:
- `ProjectMetadataCache`: Loads rooms and loops data daily.
- `loop_name` column added to `rcu_action_events` table.
- Processor logic updated to perform lookup.
### 2. [Feature: Feature Toggle Loop Name Generation](./feature-toggle-loop-name-generation.md)
- **Goal**: Provide a configuration switch to control the fallback behavior when cache lookup fails.
- **Key Components**:
- `ENABLE_LOOP_NAME_AUTO_GENERATION` env var.
- Logic to generate `[Type-Addr-Loop]` format only if enabled.
- Default behavior is `true` (enabled).
## Implementation Status
- All proposed features have been implemented and verified via unit tests.
- Configuration variables are documented in `.env.example`.