update
This commit is contained in:
@@ -177,6 +177,23 @@ class ServiceMonitorService {
|
||||
}
|
||||
|
||||
async getStatusSummary(): Promise<StatusSummary> {
|
||||
// Read latest stored ping results instead of triggering a new ping cycle
|
||||
try {
|
||||
const { rows } = await pool.query(`
|
||||
SELECT DISTINCT ON (service_id) service_id, status
|
||||
FROM service_ping_history
|
||||
ORDER BY service_id, checked_at DESC
|
||||
`);
|
||||
if (rows.length > 0) {
|
||||
return {
|
||||
up: rows.filter((r: any) => r.status === 'up').length,
|
||||
total: rows.length,
|
||||
};
|
||||
}
|
||||
} catch {
|
||||
// Fall through to live ping if no history
|
||||
}
|
||||
// Fallback: no history yet — do a live ping
|
||||
const results = await this.pingAll();
|
||||
return {
|
||||
up: results.filter((r) => r.status === 'up').length,
|
||||
|
||||
Reference in New Issue
Block a user