fix(models): null value checking

This commit is contained in:
2023-10-16 01:14:34 +08:00
parent c7de60ee03
commit 62c85e9e82

View File

@ -1,6 +1,6 @@
from typing import Optional from typing import Optional
from sqlalchemy import TEXT, case, func, inspect, select from sqlalchemy import TEXT, case, func, inspect, select, text
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column
from sqlalchemy_utils import create_view from sqlalchemy_utils import create_view
@ -78,10 +78,16 @@ class ScoreCalculated(ScoresViewBase):
Score.score, Score.score,
Score.pure, Score.pure,
( (
case(
(
(ChartInfo.notes.isnot(None) & ChartInfo.notes != 0),
Score.score Score.score
- func.floor( - func.floor(
(Score.pure * 10000000.0 / ChartInfo.notes) (Score.pure * 10000000.0 / ChartInfo.notes)
+ (Score.far * 0.5 * 10000000.0 / ChartInfo.notes) + (Score.far * 0.5 * 10000000.0 / ChartInfo.notes)
),
),
else_=text("NULL"),
) )
).label("shiny_pure"), ).label("shiny_pure"),
Score.far, Score.far,