Skip to content

Commit

Permalink
Eur rates are showing as float
Browse files Browse the repository at this point in the history
  • Loading branch information
coolfire1231 committed Aug 2, 2021
1 parent 71d0922 commit 8a5dd60
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions controller/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion daily.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 8a5dd60

Please sign in to comment.