fix: translate_eval_formula bug2
This commit is contained in:
parent
2e4f6f0445
commit
836c2a2baf
|
@ -27,10 +27,8 @@ def translate_eval_formula(exp_str: str, year: int, month: int, day: int, hour:
|
||||||
matches = re.findall(pattern, exp_str)
|
matches = re.findall(pattern, exp_str)
|
||||||
for match in matches:
|
for match in matches:
|
||||||
mpst = MpointStat.objects.filter(Q(mpoint__id=match) | Q(mpoint__name=match) | Q(mpoint__code=match), type="hour", year=year, month=month, day=day, hour=hour).first()
|
mpst = MpointStat.objects.filter(Q(mpoint__id=match) | Q(mpoint__name=match) | Q(mpoint__code=match), type="hour", year=year, month=month, day=day, hour=hour).first()
|
||||||
val = 0
|
|
||||||
if mpst:
|
if mpst:
|
||||||
val = mpst.val
|
exp_str = exp_str.replace(f"${{{match}}}", str(mpst.val))
|
||||||
exp_str = exp_str.replace(f"${{{match}}}", str(val))
|
|
||||||
rval = eval(exp_str)
|
rval = eval(exp_str)
|
||||||
return rval
|
return rval
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue