feat: cap job_runs history at last 10 per job
Tailscale, Patchmon, and Semaphore sync jobs all wrote into a shared job_runs table with no retention. With default poll intervals of 15-60 minutes, history grew unbounded. - Add pruneJobRuns(jobId) and pruneAllJobRuns() helpers. - Prune after every completeJobRun() so new runs trim old ones. - Prune once on init() to clean up existing over-cap rows. - Prune in importJobs() so re-imported runs are also capped. - Defensive LIMIT 10 in getJobRuns() for the read path. No UI changes needed — _renderRunList already renders whatever the server returns. No schema migration — only row deletions. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -450,4 +450,17 @@ describe('job_runs', () => {
|
||||
expect(runs[0].id).toBe(r2);
|
||||
expect(runs[1].id).toBe(r1);
|
||||
});
|
||||
|
||||
it('caps history at the last 10 runs per job', () => {
|
||||
createJob(baseJob);
|
||||
const id = getJobs()[0].id;
|
||||
for (let i = 0; i < 15; i++) {
|
||||
const runId = createJobRun(id);
|
||||
completeJobRun(runId, 'success', `run ${i}`);
|
||||
}
|
||||
const runs = getJobRuns(id);
|
||||
expect(runs).toHaveLength(10);
|
||||
expect(runs[0].result).toBe('run 14');
|
||||
expect(runs[9].result).toBe('run 5');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user