From 8a5dd607f33e67ff592cab5b4b8d6deb63189209 Mon Sep 17 00:00:00 2001 From: coolfire1231 Date: Mon, 2 Aug 2021 11:22:19 +0530 Subject: [PATCH] Eur rates are showing as float --- controller/api.js | 7 ++++--- daily.py | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/controller/api.js b/controller/api.js index f9860ec..4fb2c56 100644 --- a/controller/api.js +++ b/controller/api.js @@ -20,13 +20,14 @@ async function latestData (req, res, next) { fields[symbol] = 1 } } - console.log(query) - console.log(fields) const cursor = collection.find(query, { fields: fields }).sort({ date: -1 }).limit(1).toArray(function (err, result) { if (err) throw err dbo.close() if (result[0]) { - console.log(result[0]) + currency_keys = Object.keys(result[0]['rates']) + for (let key of currency_keys) { + result[0]['rates'][key] = parseFloat(result[0]['rates'][key]) + } res.writeHead(200, { 'Content-Type': 'text/json' }) res.write(JSON.stringify(result[0])) } else { diff --git a/daily.py b/daily.py index 845ea51..d9303c3 100644 --- a/daily.py +++ b/daily.py @@ -42,7 +42,7 @@ 'base': cbBase['#text'], 'rates': {} } - record_data[date]['rates'][exchangeRate['cb:targetCurrency']] = cbValue['#text'] + record_data[date]['rates'][exchangeRate['cb:targetCurrency']] = float(cbValue['#text']) def calculate_new_base(new_base, new_row):