Fix propagation data type conversion from PostgreSQL database #107
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The propagation page was showing accurate data but crashing when trying to display values retrieved from the database. The issue was that PostgreSQL DECIMAL fields are returned as strings when queried, but the frontend React component expected numbers to call
.toFixed()methods on them.Root Cause
PostgreSQL's
DECIMALtype fields in thesolar_activitytable were defined as:When these values were saved to the database and retrieved, they came back as strings (e.g.,
"107.60") instead of numbers (107.60). The frontend code attempted to call.toFixed(1)on these string values, causing a runtime error:Changes Made
Backend Model Fix
src/models/Propagation.tsfor all database query methodsSolarActivityRowinterface to handle the database string types before conversionsaveSolarActivity(),getLatestSolarActivity(), andgetSolarActivityRange()methods to convert DECIMAL strings to numbers usingparseFloat()Frontend Defensive Coding
src/app/propagation/page.tsxto handle both string and number types safely:Testing
The propagation page now correctly displays solar activity data (Solar Flux Index: 107.6, A-Index: 9.4, K-Index: 0.4) and HF band conditions with proper type handling for both in-memory simulated data and database-persisted values.
Fixes #91.
Warning
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
services.swpc.noaa.govnext-server (v15.3.5)(dns block)If you need me to access, download, or install something from one of these locations, you can either:
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.