mirror of
https://github.com/gnmyt/myspeed.git
synced 2026-05-04 19:20:25 -05:00
Updated the speedtests.js controller
This commit is contained in:
@@ -13,6 +13,14 @@ module.exports.getOne = async (id) => {
|
||||
return speedtest
|
||||
}
|
||||
|
||||
module.exports.listAll = async () => {
|
||||
let dbEntries = await tests.findAll({order: [["created", "DESC"]]});
|
||||
for (let dbEntry of dbEntries)
|
||||
if (dbEntry.error === null) delete dbEntry.error;
|
||||
|
||||
return dbEntries;
|
||||
}
|
||||
|
||||
module.exports.listTests = async (hours = 24, start, limit) => {
|
||||
limit = parseInt(limit) || 10;
|
||||
const whereClause = start ? {id: {[Op.lt]: start}} : undefined;
|
||||
|
||||
@@ -9,12 +9,12 @@ app.get("/", password(false), async (req, res) => {
|
||||
|
||||
app.get("/tests/history/json", password(false), async (req, res) => {
|
||||
res.set({"Content-Disposition": "attachment; filename=\"speedtests.json\""});
|
||||
res.send(JSON.stringify(await tests.listTests(), null, 4));
|
||||
res.send(JSON.stringify(await tests.listAll(), null, 4));
|
||||
});
|
||||
|
||||
app.get("/tests/history/csv", password(false), async (req, res) => {
|
||||
res.set({"Content-Disposition": "attachment; filename=\"speedtests.csv\""});
|
||||
let list = await tests.listTests();
|
||||
let list = await tests.listAll();
|
||||
|
||||
if (list.length === 0) return res.send("");
|
||||
let fields = Object.keys(list[0]);
|
||||
|
||||
Reference in New Issue
Block a user