Skip to content

Add admin summary API endpoint#254

Merged
marcpope merged 1 commit intomarcpope:mainfrom
c0dr1ver:feature/api-summary-request
May 6, 2026
Merged

Add admin summary API endpoint#254
marcpope merged 1 commit intomarcpope:mainfrom
c0dr1ver:feature/api-summary-request

Conversation

@c0dr1ver
Copy link
Copy Markdown
Contributor

@c0dr1ver c0dr1ver commented May 6, 2026

Summary

Adds a new token-authenticated admin API method, GET /api/v1/summary, that returns each client with its backup plans and the latest backup job result for each plan.

This gives bots and other automation a much easier way to fetch a compact summary of the current system state without stitching together client, plan, and job history calls manually.

Changes

  • Registers GET /api/v1/summary in the admin API routes.
  • Adds AdminApiController::summary() to return clients, backup plan names, latest backup result, duration, and job timestamps.
  • Documents the new method and a curl example in /settings?tab=api.

Example:

user@workstation ~> curl -X GET https://bbs.yourserver.net/api/v1/summary \
                     -H "Authorization: Bearer bbs_tok_***" | jq
{
  "clients": [
    {
      "id": 5,
      "name": "Agent 1",
      "status": "online",
      "backup_plans": [
        {
          "id": 6,
          "name": "Daily backup to local",
          "last_backup": {
            "job_id": 256,
            "result": "failed",
            "duration_seconds": 3,
            "queued_at": "2026-05-05 21:00:01",
            "started_at": "2026-05-05 21:00:19",
            "completed_at": "2026-05-05 21:00:22"
          }
        }
      ]
    },
    {
      "id": 1,
      "name": "Agent 2",
      "status": "online",
      "backup_plans": [
        {
          "id": 1,
          "name": "Daily backup to remote",
          "last_backup": {
            "job_id": 259,
            "result": "failed",
            "duration_seconds": 839,
            "queued_at": "2026-05-05 22:00:01",
            "started_at": "2026-05-05 22:00:16",
            "completed_at": "2026-05-05 22:14:15"
          }
        },
        {
          "id": 5,
          "name": "Daily backup to local",
          "last_backup": {
            "job_id": 260,
            "result": "completed",
            "duration_seconds": 3597,
            "queued_at": "2026-05-05 22:00:01",
            "started_at": "2026-05-05 22:14:16",
            "completed_at": "2026-05-05 23:14:13"
          }
        }
      ]
    },
  ]
}

Validation

  • php -l src/Core/App.php
  • php -l src/Controllers/Api/AdminApiController.php
  • php -l src/Views/settings/index.php

Testing

  • Tested on Docker
  • Tested on bare metal

@marcpope marcpope merged commit 4229af6 into marcpope:main May 6, 2026
marcpope added a commit that referenced this pull request May 7, 2026
- Admin summary API: filter latest backup to terminal statuses only;
  was reporting in-flight queued/sent/running jobs as last_backup_result
  and ordering by COALESCE(completed/started/queued) which actively
  preferred in-flight jobs over the last truly finished one.
- Queue page: header counters and metric tiles now refresh from
  /queue/json alongside the tables. Previously the slot counters,
  24h totals, and avg-duration drifted to stale values within 10s
  of page load while the live tables below them updated.
- Schedules: when the latest failure for a plan happened in a prior
  week, fall back to the most recent past block in the current week
  so the error state stays visible after the week rolls over. The
  strict 'scheduled before failure' rule was silently dropping the
  marker because every current-week block's scheduled_at_utc sat
  after the failure timestamp.
marcpope added a commit that referenced this pull request May 7, 2026
#244 black box: drop h-100 on Job Details/Stats cards so each sizes to
its own content. The cards were forcing equal height, leaving phantom
dark filler at the bottom of whichever side had fewer rows. Also remove
the dead inline 'background-color: #2c3e50' on the active progress
panel (the .queue-progress-panel gradient was already overriding it
with !important) and the now-unused dark-mode .queue-stats-panel rule.

#254 summary endpoint: rewrite the latest-job lookup as ROW_NUMBER()
over a derived table instead of a per-row correlated subquery; expose
plan.enabled, repository_id, and repository_name so consumers can tell
disabled plans apart and correlate to a repo without a second call.

#251 schedule controller: bound both the median-duration query and
the latest-terminal-job query to the last 30 days and limit results
via window functions; previously each page load scanned every
historical job for every plan ever scheduled. Failed schedule blocks
on today's lane now keep a clickable minimum width — they were
previously allowed to shrink to a 1-pixel sliver as time elapsed.

#253 cosmetics: humanize task_type ('s3 sync' instead of 's3_sync')
and escape it in both server-rendered and JS-built rows; restore
.bg-opacity-10 utility on metric tile icon backgrounds for
consistency with the dashboard; drop the hardcoded .queue-pill
'active' class which was decorative-only and didn't track the
in-page section.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants