rename: checks → pings throughout (DB, API, UI, Rust)
This commit is contained in:
@@ -18,7 +18,7 @@ export const internal = new Elysia({ prefix: "/internal", detail: { hide: true }
|
||||
SELECT m.id, m.url, m.interval_s, m.query
|
||||
FROM monitors m
|
||||
LEFT JOIN LATERAL (
|
||||
SELECT checked_at FROM check_results
|
||||
SELECT checked_at FROM pings
|
||||
WHERE monitor_id = m.id
|
||||
ORDER BY checked_at DESC LIMIT 1
|
||||
) last ON true
|
||||
|
||||
@@ -35,7 +35,7 @@ export const monitors = new Elysia({ prefix: "/monitors" })
|
||||
if (!monitor) return error(404, { error: "Not found" });
|
||||
|
||||
const results = await sql`
|
||||
SELECT * FROM check_results WHERE monitor_id = ${params.id}
|
||||
SELECT * FROM pings WHERE monitor_id = ${params.id}
|
||||
ORDER BY checked_at DESC LIMIT 100
|
||||
`;
|
||||
return { ...monitor, results };
|
||||
@@ -77,15 +77,15 @@ export const monitors = new Elysia({ prefix: "/monitors" })
|
||||
}, { detail: { summary: "Toggle monitor on/off", tags: ["monitors"] } })
|
||||
|
||||
// Check history
|
||||
.get("/:id/history", async ({ accountId, params, query, error }) => {
|
||||
.get("/:id/pings", async ({ accountId, params, query, error }) => {
|
||||
const [monitor] = await sql`
|
||||
SELECT id FROM monitors WHERE id = ${params.id} AND account_id = ${accountId}
|
||||
`;
|
||||
if (!monitor) return error(404, { error: "Not found" });
|
||||
const limit = Math.min(Number(query.limit ?? 100), 1000);
|
||||
return sql`
|
||||
SELECT * FROM check_results
|
||||
SELECT * FROM pings
|
||||
WHERE monitor_id = ${params.id}
|
||||
ORDER BY checked_at DESC LIMIT ${limit}
|
||||
`;
|
||||
}, { detail: { summary: "Get check history", tags: ["monitors"] } });
|
||||
}, { detail: { summary: "Get ping history", tags: ["monitors"] } });
|
||||
|
||||
@@ -11,7 +11,7 @@ export const ingest = new Elysia()
|
||||
if (body.cert_expiry_days != null) meta.cert_expiry_days = body.cert_expiry_days;
|
||||
|
||||
await sql`
|
||||
INSERT INTO check_results (monitor_id, status_code, latency_ms, up, error, meta)
|
||||
INSERT INTO pings (monitor_id, status_code, latency_ms, up, error, meta)
|
||||
VALUES (
|
||||
${body.monitor_id},
|
||||
${body.status_code ?? null},
|
||||
Reference in New Issue
Block a user