fix(models): null value checking

This commit is contained in:
283375 2023-10-16 01:14:34 +08:00
parent c7de60ee03
commit 62c85e9e82
Signed by: 283375
SSH Key Fingerprint: SHA256:UcX0qg6ZOSDOeieKPGokA5h7soykG61nz2uxuQgVLSk

View File

@ -1,6 +1,6 @@
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_utils import create_view
@ -78,10 +78,16 @@ class ScoreCalculated(ScoresViewBase):
Score.score,
Score.pure,
(
Score.score
- func.floor(
(Score.pure * 10000000.0 / ChartInfo.notes)
+ (Score.far * 0.5 * 10000000.0 / ChartInfo.notes)
case(
(
(ChartInfo.notes.isnot(None) & ChartInfo.notes != 0),
Score.score
- func.floor(
(Score.pure * 10000000.0 / ChartInfo.notes)
+ (Score.far * 0.5 * 10000000.0 / ChartInfo.notes)
),
),
else_=text("NULL"),
)
).label("shiny_pure"),
Score.far,