fix: Cast Decimal to float

This commit is contained in:
2025-09-24 09:44:33 +10:00
parent 0c4b2bfe32
commit 891e121e99

View File

@@ -87,32 +87,32 @@ async def prepare_subathon(profiler: ProfilesRegistry, subathon: ActiveSubathon)
last_contrib = ContributionPayload( last_contrib = ContributionPayload(
user_name=name, user_name=name,
user_id=user_id, user_id=user_id,
amount=contrib.score, amount=float(contrib.score),
seconds_added=subathon.get_score_time(contrib.score), seconds_added=subathon.get_score_time(contrib.score),
timestamp=contrib.created_at.isoformat() timestamp=contrib.created_at.isoformat()
) )
score_table = ScoreTablePayload( score_table = ScoreTablePayload(
bit_score=subathon.subathondata.bit_score, bit_score=float(subathon.subathondata.bit_score),
t1_score=subathon.subathondata.sub1_score, t1_score=float(subathon.subathondata.sub1_score),
t2_score=subathon.subathondata.sub2_score, t2_score=float(subathon.subathondata.sub2_score),
t3_score=subathon.subathondata.sub3_score, t3_score=float(subathon.subathondata.sub3_score),
score_time=subathon.subathondata.score_time, score_time=int(subathon.subathondata.score_time),
) )
payload = SubathonPayload( payload = SubathonPayload(
name=subathon.subathondata.name, name=subathon.subathondata.name,
end_at=(await subathon.get_ending()).isoformat(), end_at=(await subathon.get_ending()).isoformat(),
is_running=(subathon.running), is_running=(subathon.running),
score_table=score_table, score_table=score_table,
total_contribution=await subathon.get_score(), total_contribution=float(await subathon.get_score()),
goals_met=goals_met, goals_met=goals_met,
goals_total=total_goals, goals_total=total_goals,
last_goal=GoalPayload( last_goal=GoalPayload(
required=last_goal.required_score, required=float(last_goal.required_score),
name=last_goal.description, name=last_goal.description,
) if last_goal is not None else None, ) if last_goal is not None else None,
next_goal=GoalPayload( next_goal=GoalPayload(
required=next_goal.required_score, required=float(next_goal.required_score),
name=next_goal.description, name=next_goal.description,
) if next_goal is not None else None, ) if next_goal is not None else None,
last_contribution=last_contrib last_contribution=last_contrib