[status page] implement rest api for heartbeat

This commit is contained in:
LouisLam
2021-09-19 23:24:51 +08:00
parent 6350c43cc3
commit 7ee98d989c
5 changed files with 67 additions and 38 deletions

View File

@@ -4,17 +4,7 @@ const { R } = require("redbean-node");
class Group extends BeanModel {
async toPublicJSON() {
let monitorBeanList = R.convertToBeans("monitor", await R.getAll(`
SELECT * FROM monitor, monitor_group
WHERE monitor.id = monitor_group.monitor_id
AND group_id = ?
`, [
this.id,
]));
console.log(monitorBeanList);
let monitorBeanList = await this.getMonitorList();
let monitorList = [];
for (let bean of monitorBeanList) {
@@ -28,6 +18,16 @@ class Group extends BeanModel {
monitorList,
};
}
async getMonitorList() {
return R.convertToBeans("monitor", await R.getAll(`
SELECT monitor.* FROM monitor, monitor_group
WHERE monitor.id = monitor_group.monitor_id
AND group_id = ?
`, [
this.id,
]));
}
}
module.exports = Group;