From 3d66b82c88b209f4cd55cecc169e15b4b32142f3 Mon Sep 17 00:00:00 2001 From: nmemmert <67961292+nmemmert@users.noreply.github.com> Date: Mon, 15 Dec 2025 10:26:39 -0500 Subject: [PATCH] History API: return up to 100 checks per resource by default (separate from page size) --- server/index.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/server/index.js b/server/index.js index 1f56eb7..6e3b702 100644 --- a/server/index.js +++ b/server/index.js @@ -419,13 +419,16 @@ app.get('/api/resources/:id/history', (req, res) => { // Get all resources' check history for dashboard (optimized with aggregation) app.get('/api/history/overview', (req, res) => { - const { days = 7, limit = 12, page = 1, page: pageParam } = req.query; - const pageLimit = parseInt(req.query.limit || 10); // Pagination limit (per page) + const { days = 7, page = 1, page: pageParam } = req.query; + // Resource pagination (number of resources per page) + const pageLimit = parseInt(req.query.limit || 10); + // Per-resource checks to return (independent of pageLimit) + const checksLimit = parseInt(req.query.checks_limit || 100); const currentPage = Math.max(1, parseInt(pageParam || page || 1)); const offset = (currentPage - 1) * pageLimit; // Create cache key based on query parameters - const cacheKey = `history:days=${days}:page=${currentPage}:limit=${pageLimit}`; + const cacheKey = `history:days=${days}:page=${currentPage}:limit=${pageLimit}:checks=${checksLimit}`; // Check cache first const cachedResult = cache.get(cacheKey); @@ -467,7 +470,7 @@ app.get('/api/history/overview', (req, res) => { WHERE resource_id = ? AND checked_at > datetime('now', ?) ORDER BY checked_at DESC LIMIT ? - `).all(resource.id, `-${days} days`, parseInt(limit)); + `).all(resource.id, `-${days} days`, checksLimit); return { id: resource.id,