From e18961eb6c1bee6a42ce8040063ec4ed48a2cd2d Mon Sep 17 00:00:00 2001 From: Mathias Wagner Date: Tue, 21 May 2024 14:31:44 +0200 Subject: [PATCH] Updated the provider parser --- server/util/providers/parseData.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/server/util/providers/parseData.js b/server/util/providers/parseData.js index c06aecb1..5e263251 100644 --- a/server/util/providers/parseData.js +++ b/server/util/providers/parseData.js @@ -1,19 +1,20 @@ -const roundSpeed = (bytes, elapsed) => { - return Math.round((bytes * 8 / elapsed) / 10) / 100; +const roundSpeed = (bandwidth) => { + return Math.round(bandwidth / 1250) / 100; } module.exports.parseOokla = (test) => { let ping = Math.round(test.ping.latency); - let download = roundSpeed(test.download.bytes, test.download.elapsed); - let upload = roundSpeed(test.upload.bytes, test.upload.elapsed); + let download = roundSpeed(test.download.bandwidth); + let upload = roundSpeed(test.upload.bandwidth); let time = Math.round((test.download.elapsed + test.upload.elapsed) / 1000); - return {ping, download, upload, time}; + return {ping, download, upload, time, resultId: test.result.id}; } -module.exports.parseLibre = (test) => ({...test, time: Math.round(test.elapsed / 1000)}); +module.exports.parseLibre = (test) => ({...test, ping: Math.round(test.ping), time: Math.round(test.elapsed / 1000), + resultId: null}); -module.exports.parseCloudflare = (test) => ({...test, time: Math.round(test.elapsed)}); +module.exports.parseCloudflare = (test) => ({...test, time: Math.round(test.elapsed), resultId: null}); module.exports.parseData = (provider, data) => { switch (provider) {