Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
59 lines
2.0 KiB
Plaintext
59 lines
2.0 KiB
Plaintext
import { jobStatsGlobalSlug } from '../../config/global.js';
|
|
import { getCurrentDate } from '../../utilities/getCurrentDate.js';
|
|
export const defaultAfterSchedule = async ({ jobStats, queueable, req })=>{
|
|
const existingQueuesConfig = jobStats?.stats?.scheduledRuns?.queues?.[queueable.scheduleConfig.queue] || {};
|
|
const queueConfig = {
|
|
...existingQueuesConfig
|
|
};
|
|
if (queueable.taskConfig) {
|
|
;
|
|
(queueConfig.tasks ??= {})[queueable.taskConfig.slug] = {
|
|
lastScheduledRun: getCurrentDate().toISOString()
|
|
};
|
|
} else if (queueable.workflowConfig) {
|
|
;
|
|
(queueConfig.workflows ??= {})[queueable.workflowConfig.slug] = {
|
|
lastScheduledRun: getCurrentDate().toISOString()
|
|
};
|
|
}
|
|
// Add to payload-jobs-stats global regardless of the status
|
|
if (jobStats) {
|
|
await req.payload.db.updateGlobal({
|
|
slug: jobStatsGlobalSlug,
|
|
data: {
|
|
...jobStats || {},
|
|
stats: {
|
|
...jobStats?.stats || {},
|
|
scheduledRuns: {
|
|
...jobStats?.stats?.scheduledRuns || {},
|
|
queues: {
|
|
...jobStats?.stats?.scheduledRuns?.queues || {},
|
|
[queueable.scheduleConfig.queue]: queueConfig
|
|
}
|
|
}
|
|
},
|
|
updatedAt: new Date().toISOString()
|
|
},
|
|
req,
|
|
returning: false
|
|
});
|
|
} else {
|
|
await req.payload.db.createGlobal({
|
|
slug: jobStatsGlobalSlug,
|
|
data: {
|
|
createdAt: getCurrentDate().toISOString(),
|
|
stats: {
|
|
scheduledRuns: {
|
|
queues: {
|
|
[queueable.scheduleConfig.queue]: queueConfig
|
|
}
|
|
}
|
|
}
|
|
},
|
|
req,
|
|
returning: false
|
|
});
|
|
}
|
|
};
|
|
|
|
//# sourceMappingURL=defaultAfterSchedule.js.map |