feat(etl): cfg_* 视图入口统一 + NULL 兼容 + 3 处 _load_* 历史 Bug (W1-T2 / P0-1)
Wave 1 Day 3 沙箱配置参数切片。 DB 迁移 (20260504__cfg_views_null_compatible.sql): - 4 个 v_cfg_* 视图 WHERE 加 NULL 兼容 (effective_to IS NULL OR effective_to >= ...) - 顺手清理 v_cfg_assistant_level_price / v_cfg_performance_tier WHERE 重复一次的 bug - 测试库已执行,4 校验 PASS ETL 代码 (4 处 SQL): - base_index_task.py: FROM dws.cfg_index_parameters -> app.v_cfg_index_parameters - base_dws_task.py 3 处 _load_* (performance_tier / level_price / bonus_rules) 改 FROM app.v_cfg_*,顺手修历史 Bug:原 SQL 不带 effective_from/to WHERE 效果: - 修复视图 NULL 行被过滤问题(SPI 27 行原本读到 0) - 沙箱模式回放历史日期时,参数自动按 sandbox_date 切片 - _load_* 直接得到当前生效行(原 12/9 行历史 Python 挑) 参考: - docs/audit/changes/2026-05-04__wave1_t2_scd2_view_unify.md - docs/database/changes/2026-05-04__cfg_views_null_compatible.md
This commit is contained in:
@@ -533,48 +533,60 @@ class BaseDwsTask(BaseTask):
|
||||
def _load_performance_tiers(self) -> List[Dict[str, Any]]:
|
||||
"""
|
||||
加载绩效档位配置
|
||||
|
||||
|
||||
字段说明(来自DWS数据库处理需求.md):
|
||||
- base_deduction: 专业课抽成(元/小时),球房从基础课每小时扣除的金额
|
||||
- bonus_deduction_ratio: 打赏课抽成比例,球房从附加课收入中扣除的比例
|
||||
- vacation_days: 次月可休假天数
|
||||
- vacation_unlimited: 休假自由标记(最高档为TRUE)
|
||||
|
||||
Wave 1 W1-T2(2026-05-04):走 app.v_cfg_performance_tier 视图,
|
||||
视图按 app.business_date_now() 切片,沙箱模式下自动取 sandbox_date 当时生效行。
|
||||
修复历史 Bug:原 SQL 不带 effective_from/to WHERE,把全部历史区间拉给 Python 挑。
|
||||
"""
|
||||
sql = """
|
||||
SELECT
|
||||
SELECT
|
||||
tier_id, tier_code, tier_name, tier_level,
|
||||
min_hours, max_hours,
|
||||
base_deduction, bonus_deduction_ratio,
|
||||
min_hours, max_hours,
|
||||
base_deduction, bonus_deduction_ratio,
|
||||
vacation_days, vacation_unlimited,
|
||||
is_new_hire_tier, effective_from, effective_to
|
||||
FROM dws.cfg_performance_tier
|
||||
FROM app.v_cfg_performance_tier
|
||||
ORDER BY tier_level ASC, effective_from ASC
|
||||
"""
|
||||
rows = self.db.query(sql)
|
||||
return [dict(row) for row in rows] if rows else []
|
||||
|
||||
|
||||
def _load_level_prices(self) -> List[Dict[str, Any]]:
|
||||
"""加载等级定价配置"""
|
||||
"""加载等级定价配置
|
||||
|
||||
Wave 1 W1-T2(2026-05-04):走 app.v_cfg_assistant_level_price 视图,
|
||||
修复历史 Bug:原 SQL 不带 effective_from/to WHERE。
|
||||
"""
|
||||
sql = """
|
||||
SELECT
|
||||
SELECT
|
||||
price_id, level_code, level_name,
|
||||
base_course_price, bonus_course_price,
|
||||
effective_from, effective_to
|
||||
FROM dws.cfg_assistant_level_price
|
||||
FROM app.v_cfg_assistant_level_price
|
||||
ORDER BY level_code ASC, effective_from DESC
|
||||
"""
|
||||
rows = self.db.query(sql)
|
||||
return [dict(row) for row in rows] if rows else []
|
||||
|
||||
|
||||
def _load_bonus_rules(self) -> List[Dict[str, Any]]:
|
||||
"""加载奖金规则配置"""
|
||||
"""加载奖金规则配置
|
||||
|
||||
Wave 1 W1-T2(2026-05-04):走 app.v_cfg_bonus_rules 视图,
|
||||
修复历史 Bug:原 SQL 不带 effective_from/to WHERE。
|
||||
"""
|
||||
sql = """
|
||||
SELECT
|
||||
SELECT
|
||||
rule_id, rule_type, rule_code, rule_name,
|
||||
threshold_hours, rank_position, bonus_amount,
|
||||
is_cumulative, priority,
|
||||
effective_from, effective_to
|
||||
FROM dws.cfg_bonus_rules
|
||||
FROM app.v_cfg_bonus_rules
|
||||
ORDER BY rule_type, priority DESC, effective_from DESC
|
||||
"""
|
||||
rows = self.db.query(sql)
|
||||
|
||||
@@ -332,12 +332,13 @@ class BaseIndexTask(BaseDwsTask):
|
||||
|
||||
self.logger.debug("加载指数算法参数: %s", index_type)
|
||||
|
||||
# Wave 1 W1-T2(2026-05-04):走 app.v_cfg_index_parameters 视图,
|
||||
# 视图按 app.business_date_now() 切片(GUC app.current_business_date 决定),
|
||||
# 沙箱模式下自动读取 sandbox_date 当时生效的参数版本。
|
||||
sql = """
|
||||
SELECT param_name, param_value
|
||||
FROM dws.cfg_index_parameters
|
||||
FROM app.v_cfg_index_parameters
|
||||
WHERE index_type = %s
|
||||
AND effective_from <= CURRENT_DATE
|
||||
AND (effective_to IS NULL OR effective_to >= CURRENT_DATE)
|
||||
ORDER BY effective_from DESC
|
||||
"""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user