15 lines
588 B
JavaScript
15 lines
588 B
JavaScript
import { pool } from '../pool.js';
|
|
export async function upsert({ service_id, status, latency_ms = null, detail = null }) {
|
|
await pool.query(
|
|
`INSERT INTO service_status (service_id, status, latency_ms, detail, checked_at)
|
|
VALUES ($1,$2,$3,$4, now())
|
|
ON CONFLICT (service_id) DO UPDATE
|
|
SET status=EXCLUDED.status, latency_ms=EXCLUDED.latency_ms,
|
|
detail=EXCLUDED.detail, checked_at=now()`,
|
|
[service_id, status, latency_ms, detail]);
|
|
}
|
|
export async function all() {
|
|
const { rows } = await pool.query(`SELECT * FROM service_status`);
|
|
return rows;
|
|
}
|