mirror of
https://github.com/gnmyt/myspeed.git
synced 2026-01-07 21:49:48 -06:00
17 lines
649 B
JavaScript
17 lines
649 B
JavaScript
const db = require('../index').database;
|
|
|
|
// Gets the current recommendations
|
|
module.exports.get = () => {
|
|
return db.prepare("SELECT * FROM recommendations").get();
|
|
}
|
|
|
|
// Sets new recommendations
|
|
module.exports.set = (ping, download, upload) => {
|
|
if (this.get() === undefined) {
|
|
return db.prepare("INSERT INTO recommendations (ping, download, upload) VALUES (?, ?, ?)")
|
|
.run(Math.round(ping), download.toFixed(2), upload.toFixed(2));
|
|
} else {
|
|
return db.prepare("UPDATE recommendations SET ping = ?, download = ?, upload = ?")
|
|
.run(Math.round(ping), download.toFixed(2), upload.toFixed(2));
|
|
}
|
|
} |