Hub 2.6.0: paged lists, job status filters, one-product updates, installs found on servers

- Jobs: Succeeded/Cancelled filters, product, type and church search, paged
  on the server; audit log and alerts paged on the server with search;
  every other list paged.
- Updates: one product at a time with its own releases; an Events update
  pins the church's Accounts (or updates it when the release needs it, or
  installs it first); fixes the requirement check comparing an object.
- A status job adds installs found on a server and ties them to their
  registration; unlinked registered sites trigger one (daily); heartbeats
  tie install records too; the install page shows its registration.
13 new tests (209).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-19 20:09:31 +02:00
co-authored by Claude Opus 5.5
parent ff176681a7
commit de6a14c229
24 changed files with 641 additions and 130 deletions
+8 -6
View File
@@ -11,6 +11,7 @@ const { audit } = require('../utils/audit');
const { getSettings, setSettings } = require('../utils/settings');
const servers = require('../utils/servers');
const jobs = require('../utils/jobs');
const { pageOf, paged } = require('../utils/paging');
const router = express.Router();
router.use(protect);
@@ -216,15 +217,16 @@ router.post('/updates', wrap(async (req, res) => {
// ─── Jobs ─────────────────────────────────────────────────────────────────────
// Hub 2.6.0: paged (?page, ?pageSize), with filters for every status (succeeded too), a job type,
// a product, a server, an install, and a search on the church's short name or domain.
router.get('/jobs', wrap(async (req, res) => {
const where = {};
if (req.query.status) where.status = String(req.query.status);
if (req.query.serverId) where.serverId = String(req.query.serverId);
if (req.query.upcoming === 'true') where.status = { in: ['queued', 'scheduled', 'delivered'] };
const list = await prisma.job.findMany({ where, orderBy: [{ notBefore: 'desc' }], take: 200, include: { server: { select: { id: true, name: true } }, deployment: { select: { id: true, shortName: true, domain: true } } } });
res.json({ jobs: list.map(j => ({ ...j, report: undefined, hasReport: !!j.report })) });
const where = await jobs.listWhere(req.query);
const p = pageOf(req.query);
const out = await paged(prisma.job, { where, orderBy: [{ notBefore: 'desc' }, { createdAt: 'desc' }], include: { server: { select: { id: true, name: true } }, deployment: { select: { id: true, shortName: true, domain: true, product: true } } } }, p);
res.json({ jobs: out.rows.map(j => ({ ...j, report: undefined, hasReport: !!j.report })), total: out.total, page: out.page, pageSize: out.pageSize, pages: out.pages });
}));
router.get('/jobs/:id', wrap(async (req, res) => {
const job = await prisma.job.findUnique({ where: { id: req.params.id }, include: { server: { select: { id: true, name: true } }, deployment: { select: { id: true, shortName: true, domain: true } } } });
if (!job) throw bad('Not found.', 404);