From 513768acd0a2af1bd588f7fdcf3f16ff22746118 Mon Sep 17 00:00:00 2001 From: Mathias Wagner Date: Sat, 9 Apr 2022 23:10:24 +0200 Subject: [PATCH] Updated the speedtest controller --- server/controller/speedtests.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/server/controller/speedtests.js b/server/controller/speedtests.js index cef04b1a..c594355e 100644 --- a/server/controller/speedtests.js +++ b/server/controller/speedtests.js @@ -2,7 +2,8 @@ const db = require('../index').database; // Inserts a new speedtest into the database module.exports.create = (ping, download, upload) => { - return db.prepare("INSERT INTO speedtests (ping, download, upload) VALUES (?, ?, ?)").run(ping, download, upload).lastInsertRowid; + return db.prepare("INSERT INTO speedtests (ping, download, upload, created) VALUES (?, ?, ?, ?)").run(ping, download, upload, + new Date().toISOString()).lastInsertRowid; } // Gets a specific speedtest by id @@ -12,7 +13,7 @@ module.exports.get = (id) => { // Lists all speedtests from the database module.exports.list = () => { - return db.prepare("SELECT * FROM speedtests").all(); + return db.prepare("SELECT * FROM speedtests ORDER BY created DESC").all(); } // Gets the latest speedtest from the database