mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-02-12 20:52:52 -05:00
removed unneccesory comment
This commit is contained in:
parent
ae7f01b3ea
commit
bb499e2aa1
@ -1646,10 +1646,8 @@ async function afterLogin(socket, user) {
|
|||||||
|
|
||||||
await StatusPage.sendStatusPageList(io, socket);
|
await StatusPage.sendStatusPageList(io, socket);
|
||||||
|
|
||||||
// Create an array to store the combined promises for both sendHeartbeatList and sendStats
|
|
||||||
const monitorPromises = [];
|
const monitorPromises = [];
|
||||||
for (let monitorID in monitorList.list) {
|
for (let monitorID in monitorList.list) {
|
||||||
// Combine both sendHeartbeatList and sendStats for each monitor into a single Promise
|
|
||||||
monitorPromises.push(
|
monitorPromises.push(
|
||||||
Promise.all([
|
Promise.all([
|
||||||
sendHeartbeatList(socket, monitorID),
|
sendHeartbeatList(socket, monitorID),
|
||||||
@ -1658,7 +1656,6 @@ async function afterLogin(socket, user) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Await all combined promises
|
|
||||||
await Promise.all(monitorPromises);
|
await Promise.all(monitorPromises);
|
||||||
|
|
||||||
// Set server timezone from client browser if not set
|
// Set server timezone from client browser if not set
|
||||||
|
@ -227,11 +227,9 @@ class UptimeKumaServer {
|
|||||||
async getMonitorJSONList(userID, monitorID = null) {
|
async getMonitorJSONList(userID, monitorID = null) {
|
||||||
let result = {};
|
let result = {};
|
||||||
|
|
||||||
// Initialize query and parameters
|
|
||||||
let query = " user_id = ? ";
|
let query = " user_id = ? ";
|
||||||
let queryParams = [ userID ];
|
let queryParams = [ userID ];
|
||||||
|
|
||||||
// Add condition for monitorID if provided
|
|
||||||
if (monitorID) {
|
if (monitorID) {
|
||||||
query += "AND id = ? ";
|
query += "AND id = ? ";
|
||||||
queryParams.push(monitorID);
|
queryParams.push(monitorID);
|
||||||
@ -239,24 +237,19 @@ class UptimeKumaServer {
|
|||||||
|
|
||||||
let monitorList = await R.find("monitor", query + "ORDER BY weight DESC, name", queryParams);
|
let monitorList = await R.find("monitor", query + "ORDER BY weight DESC, name", queryParams);
|
||||||
|
|
||||||
// Collect monitor IDs
|
|
||||||
// Create monitorData with id, active
|
|
||||||
const monitorData = monitorList.map(monitor => ({
|
const monitorData = monitorList.map(monitor => ({
|
||||||
id: monitor.id,
|
id: monitor.id,
|
||||||
active: monitor.active,
|
active: monitor.active,
|
||||||
}));
|
}));
|
||||||
const preloadData = await Monitor.preparePreloadData(monitorData);
|
const preloadData = await Monitor.preparePreloadData(monitorData);
|
||||||
|
|
||||||
// Create an array of promises to convert each monitor to JSON in parallel
|
|
||||||
const monitorPromises = monitorList.map(monitor => monitor.toJSON(preloadData).then(json => {
|
const monitorPromises = monitorList.map(monitor => monitor.toJSON(preloadData).then(json => {
|
||||||
return { id: monitor.id,
|
return { id: monitor.id,
|
||||||
json
|
json
|
||||||
};
|
};
|
||||||
}));
|
}));
|
||||||
// Wait for all promises to resolve
|
|
||||||
const monitors = await Promise.all(monitorPromises);
|
const monitors = await Promise.all(monitorPromises);
|
||||||
|
|
||||||
// Populate the result object with monitor IDs as keys, JSON objects as values
|
|
||||||
monitors.forEach(monitor => {
|
monitors.forEach(monitor => {
|
||||||
result[monitor.id] = monitor.json;
|
result[monitor.id] = monitor.json;
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user