mirror of
https://github.com/aljazceru/satshkd-vercel.git
synced 2025-12-18 13:44:22 +01:00
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:
@@ -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
|
// first run convertformat then run hkdrate
|
||||||
// convertformat()
|
// convertformat()
|
||||||
|
|
||||||
hkdrate()
|
// hkdrate()
|
||||||
|
eurrate()
|
||||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user