Skip to content

Commit bb1c026

Browse files
committed
Updated the speedtests.js controller
1 parent 887a280 commit bb1c026

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

server/controller/speedtests.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ module.exports.getOne = async (id) => {
1313
return speedtest
1414
}
1515

16+
module.exports.listAll = async () => {
17+
let dbEntries = await tests.findAll({order: [["created", "DESC"]]});
18+
for (let dbEntry of dbEntries)
19+
if (dbEntry.error === null) delete dbEntry.error;
20+
21+
return dbEntries;
22+
}
23+
1624
module.exports.listTests = async (hours = 24, start, limit) => {
1725
limit = parseInt(limit) || 10;
1826
const whereClause = start ? {id: {[Op.lt]: start}} : undefined;

server/routes/storage.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ app.get("/", password(false), async (req, res) => {
99

1010
app.get("/tests/history/json", password(false), async (req, res) => {
1111
res.set({"Content-Disposition": "attachment; filename=\"speedtests.json\""});
12-
res.send(JSON.stringify(await tests.listTests(), null, 4));
12+
res.send(JSON.stringify(await tests.listAll(), null, 4));
1313
});
1414

1515
app.get("/tests/history/csv", password(false), async (req, res) => {
1616
res.set({"Content-Disposition": "attachment; filename=\"speedtests.csv\""});
17-
let list = await tests.listTests();
17+
let list = await tests.listAll();
1818

1919
if (list.length === 0) return res.send("");
2020
let fields = Object.keys(list[0]);

0 commit comments

Comments
 (0)