docs: add comments for queries

This commit is contained in:
Peace 2024-10-17 17:16:29 +02:00
parent ec2cebc5df
commit ac8d1d6346
No known key found for this signature in database
GPG key ID: 0EF6B46E172B739F

View file

@ -1607,6 +1607,7 @@ class Monitor extends BeanModel {
* @returns {Promise<Bean[]>} Active Monitors
*/
static async getAllActiveMonitors() {
// Gets all monitors but only if they and all their ancestors are active
return R.convertToBeans("monitor", await R.getAll(`
WITH RECURSIVE MonitorHierarchy AS (
SELECT * FROM monitor
@ -1683,6 +1684,7 @@ class Monitor extends BeanModel {
* @returns {Promise<number[]>} IDs of all ancestors
*/
static async getAllAncestorIDs(monitorID) {
// Gets all ancestor monitor ids recursive
return await R.getCol(`
WITH RECURSIVE Ancestors AS (
SELECT parent FROM monitor
@ -1754,6 +1756,7 @@ class Monitor extends BeanModel {
* @returns {Promise<boolean>} Is the parent monitor active?
*/
static async isParentActive(monitorID) {
// Checks recursive if the parent and all its ancestors are active
const result = await R.getRow(`
WITH RECURSIVE MonitorHierarchy AS (
SELECT parent FROM monitor