fix: align tier_from_value with DB model field names (t1_threshold)
formula_engine.tier_from_value read track.t1/t2/t3/t4 but the EvolutionTrack model defines t1_threshold/t2_threshold/etc. Updated both the function and test fixtures to use the _threshold suffix. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
f12aa858c1
commit
eba23369ca
@ -90,13 +90,23 @@ def tier_from_value(value: float, track) -> int:
|
||||
|
||||
Args:
|
||||
value: Computed formula value.
|
||||
track: Object (or dict-like) with t1, t2, t3, t4 attributes/keys.
|
||||
track: Object (or dict-like) with t1_threshold..t4_threshold attributes/keys.
|
||||
"""
|
||||
# Support both attribute-style (Peewee model) and dict (seed fixture)
|
||||
if isinstance(track, dict):
|
||||
t1, t2, t3, t4 = track["t1"], track["t2"], track["t3"], track["t4"]
|
||||
t1, t2, t3, t4 = (
|
||||
track["t1_threshold"],
|
||||
track["t2_threshold"],
|
||||
track["t3_threshold"],
|
||||
track["t4_threshold"],
|
||||
)
|
||||
else:
|
||||
t1, t2, t3, t4 = track.t1, track.t2, track.t3, track.t4
|
||||
t1, t2, t3, t4 = (
|
||||
track.t1_threshold,
|
||||
track.t2_threshold,
|
||||
track.t3_threshold,
|
||||
track.t4_threshold,
|
||||
)
|
||||
|
||||
if value >= t4:
|
||||
return 4
|
||||
|
||||
@ -43,9 +43,27 @@ def pitcher_stats(**kwargs):
|
||||
def track_dict(card_type: str) -> dict:
|
||||
"""Return the locked threshold dict for a given card_type."""
|
||||
return {
|
||||
"batter": {"card_type": "batter", "t1": 37, "t2": 149, "t3": 448, "t4": 896},
|
||||
"sp": {"card_type": "sp", "t1": 10, "t2": 40, "t3": 120, "t4": 240},
|
||||
"rp": {"card_type": "rp", "t1": 3, "t2": 12, "t3": 35, "t4": 70},
|
||||
"batter": {
|
||||
"card_type": "batter",
|
||||
"t1_threshold": 37,
|
||||
"t2_threshold": 149,
|
||||
"t3_threshold": 448,
|
||||
"t4_threshold": 896,
|
||||
},
|
||||
"sp": {
|
||||
"card_type": "sp",
|
||||
"t1_threshold": 10,
|
||||
"t2_threshold": 40,
|
||||
"t3_threshold": 120,
|
||||
"t4_threshold": 240,
|
||||
},
|
||||
"rp": {
|
||||
"card_type": "rp",
|
||||
"t1_threshold": 3,
|
||||
"t2_threshold": 12,
|
||||
"t3_threshold": 35,
|
||||
"t4_threshold": 70,
|
||||
},
|
||||
}[card_type]
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user