Files
myspeed/server/controller/recommendations.js
2023-11-30 12:32:17 +01:00

17 lines
589 B
JavaScript

const recommendations = require('../models/Recommendations');
const {triggerEvent} = require("./integrations");
module.exports.getCurrent = async () => {
return await recommendations.findOne();
}
module.exports.update = 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);
}