历史计划重放不继承当前评级排序开关

This commit is contained in:
zlt 2026-11-05 13:10:57 +08:00
parent 1278c07421
commit 0945fa2b29
2 changed files with 10 additions and 0 deletions

View File

@ -150,6 +150,9 @@ class Config:
bundle = _active.get()
if bundle is not None and name in bundle.params:
return bundle.params[name]
# 老冻结版本从未启用新规则,不能继承今天服务器的开关。
if bundle is not None and bundle.replay and name == 'PLAN_RATING_PRIORITY_ENABLED':
return False
return getattr(self.module, name)

View File

@ -69,6 +69,13 @@ class PriorityTest(unittest.TestCase):
self.assertEqual(rows['SH600001']['rating_priority']['status'],'expired')
with self.assertRaises(OSError):
sources.company_reviews(['SH600001'],'2026-11-04',read_pg=lambda sql,args: read(sql,args) if 'company_review_runs' in sql else (_ for _ in ()).throw(OSError('history unavailable')),cutoff_at=EDGE,include_rating=True)
def test_old_frozen_params_do_not_inherit_current_enabled_switch(self):
with patch.object(config, 'PLAN_RATING_PRIORITY_ENABLED', True):
with pi.Bundle(records={}, params={}).use():
self.assertFalse(plan.config.PLAN_RATING_PRIORITY_ENABLED)
with pi.Bundle(params={}).use():
self.assertTrue(plan.config.PLAN_RATING_PRIORITY_ENABLED)
def test_frozen_replay_does_not_read_or_expire(self):
source=lambda *a,**kw: {'SH600001':{**review(),'rating_priority':rating.evaluate(review(),history(),kw['cutoff_at'])}}
bundle=pi.Bundle(params={'PLAN_RATING_PRIORITY_ENABLED':True},cutoff_at='2026-11-05T08:59:00+08:00')