Closed zohassadar closed 1 year ago
Hey, thanks for opening an issue. This is a bit weird considering things work in prod and in my local setup 🤔. I'll take a look when I get home.
What version of postgres are you using?
PostgreSQL 14.5 (Debian 14.5-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
Riiiight. I just checked the prod DB, looks like I updated the datatype at some point but forgot to update setup/db.sql
🤦
Both fields das_avg
's and tetris_rate
are of type double precision
in prod (NOT numeric
), which is why they are converted to JS floats by the postgres driver. It made sense that the numeric
format would not be converted, and return a string, to ensure there's no loss in precision. That's probably why I dropped it.
I just pushed a commit to correct the DB setup file.
Sorry about that. Goes to show pretty much nobody has a local setup of NTC 😢 .
Thanks again for the report!
It was an effective way to learn about the peculiarities of different kinds of numbers in postgres.
Using your explanation combined with google, I was able to bring my existing DB up to speed with the following:
ALTER TABLE scores
ALTER COLUMN tetris_rate TYPE DOUBLE PRECISION,
ALTER COLUMN das_avg TYPE DOUBLE PRECISION;
Using an unmodified ./views/scores.ejs
afterwards I was able to load the scores page with no issue.
Thanks!!
I'm running this locally in a docker container on a Windows 10 machine with WSL2 and using the latest branch of main. I tried the docker images node:latest (currently 18.7.0) and node:14.20.0 with the same results.
http://127.0.0.1:5000/stats/scores gives the following error:
After poking at it, the value of
score.das_avg
looks like it's being provided as a string instead of a float.I was able to work around by wrapping
score.das_avg
inparseFloat()
in the line referenced by the error. The page renders correctly with this edit.Please let me know if there's any other information I can provide.