Merge pull request 'fix: queue on-create jobs sequentially and fix history ordering' (#56) from feat/jobs-system into dev
All checks were successful
CI / test (push) Successful in 13s
CI / build-dev (push) Successful in 28s

Reviewed-on: #56
This commit was merged in pull request #56.
This commit is contained in:
2026-03-28 20:12:31 -04:00
2 changed files with 4 additions and 2 deletions

View File

@@ -227,7 +227,7 @@ export function importInstances(rows, historyRows = []) {
export function getInstanceHistory(vmid) { export function getInstanceHistory(vmid) {
return db.prepare( return db.prepare(
'SELECT * FROM instance_history WHERE vmid = ? ORDER BY changed_at DESC' 'SELECT * FROM instance_history WHERE vmid = ? ORDER BY changed_at ASC, id ASC'
).all(vmid); ).all(vmid);
} }

View File

@@ -132,7 +132,9 @@ const _intervals = new Map();
export async function runJobsOnCreate() { export async function runJobsOnCreate() {
for (const job of getJobs()) { for (const job of getJobs()) {
const cfg = JSON.parse(job.config || '{}'); const cfg = JSON.parse(job.config || '{}');
if (cfg.run_on_create) runJob(job.id).catch(e => console.error(`runJobsOnCreate job ${job.id}:`, e)); if (cfg.run_on_create) {
try { await runJob(job.id); } catch (e) { console.error(`runJobsOnCreate job ${job.id}:`, e); }
}
} }
} }