Timed jobs move from in-process timers to a job registry run by pg-boss: once per schedule across processes, retries, run history, cron schedules in the church timezone, and an admin Background jobs page with Run now. Playwright end-to-end tests run against their own seeded database. A Gitea Actions workflow runs backend tests, frontend checks and the e2e tests, and deploys v* tags with scripts/deploy.sh once secrets are set. Also fixes the at-the-door check-in count for multi-day tickets. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
35 lines
1.1 KiB
JavaScript
35 lines
1.1 KiB
JavaScript
const prisma = require('../config/db');
|
|
const { safeErrorMessage } = require('../utils/errorUtils');
|
|
const { logAdminAction } = require('../utils/adminAudit');
|
|
const { getClientIp } = require('../utils/requestUtils');
|
|
const jobs = require('../jobs');
|
|
|
|
// @desc Background jobs: schedule, next run and the last 10 runs of each
|
|
// @route GET /api/admin/jobs
|
|
// @access Private/Admin
|
|
const listJobs = async (req, res) => {
|
|
try {
|
|
res.json(await jobs.jobStatus(prisma));
|
|
} catch (error) {
|
|
res.status(500).json({ message: safeErrorMessage(error) });
|
|
}
|
|
};
|
|
|
|
// @desc Run a background job now
|
|
// @route POST /api/admin/jobs/:name/run
|
|
// @access Private/Admin
|
|
const runJobNow = async (req, res) => {
|
|
try {
|
|
const result = await jobs.runNow(req.params.name);
|
|
logAdminAction({
|
|
actorId: req.user.id, actorRole: req.user.role, action: 'job_run_manual',
|
|
targetType: 'Job', targetId: req.params.name, metadata: { queued: result.queued }, ip: getClientIp(req),
|
|
});
|
|
res.json(result);
|
|
} catch (error) {
|
|
res.status(error.statusCode || 500).json({ message: safeErrorMessage(error) });
|
|
}
|
|
};
|
|
|
|
module.exports = { listJobs, runJobNow };
|