Dashboard: hide archived sessions from the All-sites list (hc-7vo)
Follow-up to the archive feature: archived healthchecks showed in both the main All-sites list and the Archived section. allSitesSummary() now excludes archived sessions from the aggregate (and from the per-site "latest session" detail), so a site whose sessions are all archived drops off the main list and appears only under "Archived". A site with a mix keeps its row, counting only its live sessions. The per-site page still lists every session. Also bumps the server version baseline in config.php.example to 0.1.8. 2 new tests (51 total). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -28,5 +28,5 @@ return [
|
||||
'db_pass' => 'REPLACE_WITH_DB_PASSWORD',
|
||||
|
||||
// Server version, surfaced on GET /. Bump on deploy.
|
||||
'version' => '0.1.0',
|
||||
'version' => '0.1.8',
|
||||
];
|
||||
|
||||
+15
-6
@@ -222,10 +222,17 @@ final class Store {
|
||||
/**
|
||||
* Summary of all sites for the dashboard: one row per site_key,
|
||||
* ordered by most-recently-active first.
|
||||
* `next_due` is taken from the most recent session, not from the most recent
|
||||
* session that happens to have one set. If the latest visit didn't schedule a
|
||||
* return, the site genuinely has nothing scheduled — carrying an older date
|
||||
* forward would show a visit as overdue immediately after it was completed.
|
||||
*
|
||||
* Archived sessions are excluded from the aggregate, so a site whose sessions
|
||||
* are all archived drops off this list entirely (it still shows, per session,
|
||||
* under the dashboard's "Archived" heading). Every column — counts, latest
|
||||
* dates, next_due — reflects only the site's non-archived sessions.
|
||||
*
|
||||
* `next_due` is taken from the most recent (non-archived) session, not from
|
||||
* the most recent one that happens to have one set. If the latest visit didn't
|
||||
* schedule a return, the site genuinely has nothing scheduled — carrying an
|
||||
* older date forward would show a visit as overdue immediately after it was
|
||||
* completed.
|
||||
*
|
||||
* @return array<int, array{site_key:string, total:int, finished:int, last_started_at:int, last_finished_at:int|null, last_reporting_url:string, next_due:string|null}>
|
||||
*/
|
||||
@@ -237,16 +244,18 @@ final class Store {
|
||||
SUM(CASE WHEN finished_at IS NOT NULL THEN 1 ELSE 0 END) AS finished,
|
||||
MAX(started_at) AS last_started_at
|
||||
FROM healthchecks
|
||||
WHERE archived = 0
|
||||
GROUP BY site_key
|
||||
ORDER BY MAX(updated_at) DESC'
|
||||
);
|
||||
$rows = $stmt->fetchAll();
|
||||
// Fetch the reporting_url and finished_at from the most recent session per site.
|
||||
// Fetch the reporting_url and finished_at from the most recent NON-archived
|
||||
// session per site (the site is only here because it has at least one).
|
||||
$out = [];
|
||||
foreach ($rows as $r) {
|
||||
$detail = Db::pdo()->prepare(
|
||||
'SELECT reporting_url, finished_at, next_due FROM healthchecks
|
||||
WHERE site_key = ? ORDER BY started_at DESC LIMIT 1'
|
||||
WHERE site_key = ? AND archived = 0 ORDER BY started_at DESC LIMIT 1'
|
||||
);
|
||||
$detail->execute([$r['site_key']]);
|
||||
$last = $detail->fetch() ?: [];
|
||||
|
||||
Reference in New Issue
Block a user