Skip to content

Commit

Permalink
update_matrix: Fix handling of data from postgres >= 14
Browse files Browse the repository at this point in the history
With Postgresql 14, EXTRACT() function returns a numeric type instead of
a float. This is converted to a Decimal by asyncpg, thus breaking code
doing a sum of all ages.

Initialising the sum with 0 instead 0.0 fixes the issue.
  • Loading branch information
jocelynj authored and frodrigo committed Apr 13, 2024
1 parent f29a048 commit 61efe73
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion control/insight.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ async def update_matrix(
for analyser in matrix:
min: Optional[float] = None
max: Optional[float] = None
sum = 0.0
sum = 0
for country in matrix[analyser]:
v = matrix[analyser][country][0]
min = v if not min or v < min else min
Expand Down

0 comments on commit 61efe73

Please sign in to comment.