mirror of
https://github.com/gnmyt/myspeed.git
synced 2026-01-19 19:49:50 -06:00
19 lines
643 B
JavaScript
19 lines
643 B
JavaScript
const recommendations = require('../models/Recommendations');
|
|
const {triggerEvent} = require("./integrations");
|
|
|
|
// Gets the current recommendations
|
|
module.exports.get = async () => {
|
|
return await recommendations.findOne();
|
|
}
|
|
|
|
// Sets new recommendations
|
|
module.exports.set = async (ping, download, upload) => {
|
|
const configuration = {ping: Math.round(ping), download: parseFloat(download.toFixed(2)),
|
|
upload: parseFloat(upload.toFixed(2))};
|
|
|
|
await recommendations.destroy({truncate: true});
|
|
|
|
triggerEvent("recommendationsUpdated", configuration).then(() => {});
|
|
|
|
return recommendations.create(configuration);
|
|
} |