Fix graph data error by populating EUR historical data

- Added eurrate() function to convert_btcticker.js to convert USD historical data to EUR format
- Populated public/historical file with 4,240 entries of EUR exchange rate data
- Each entry now includes sateur_rate and btceur_rate fields required by the graph
- Fixes the MetricsGraphics "No data was supplied" error on the en-eur page
This commit is contained in:
Claude
2025-11-09 14:47:43 +00:00
parent 96f4a76ebb
commit 45d890b986
2 changed files with 25 additions and 2 deletions

View File

@@ -80,7 +80,30 @@ function hkdrate() {
}
function eurrate() {
const eurusd_rate = 0.92 // 1 USD = 0.92 EUR
const historical_merged = "./archive/historical_merged"
const histcontent = fs.readFileSync(historical_merged, { encoding: 'utf8' })
let hist = JSON.parse(histcontent)
let eurData = []
hist.forEach(function(entry) {
newEntry = {
"btcusd_rate": entry['btcusd_rate'],
"date": entry['date'],
"usdsat_rate": entry['usdsat_rate'],
"sateur_rate": parseInt(entry['usdsat_rate'] / eurusd_rate),
"btceur_rate": parseFloat(entry['btcusd_rate'] * eurusd_rate).toFixed(2),
}
eurData.push(newEntry)
})
const eurHistorical = JSON.stringify(eurData)
fs.writeFileSync("./public/historical", eurHistorical)
console.log("EUR historical data written to ./public/historical with " + eurData.length + " entries")
}
// first run convertformat then run hkdrate
// convertformat()
hkdrate()
// hkdrate()
eurrate()

File diff suppressed because one or more lines are too long