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
47 lines
1.5 KiB
Plaintext
47 lines
1.5 KiB
Plaintext
import { jobsCollectionSlug } from '../queues/config/collection.js';
|
|
export const deleteScheduledPublishJobs = async ({ id, slug, payload, req })=>{
|
|
try {
|
|
await payload.db.deleteMany({
|
|
collection: jobsCollectionSlug,
|
|
req,
|
|
where: {
|
|
and: [
|
|
// only want to delete jobs have not run yet
|
|
{
|
|
completedAt: {
|
|
exists: false
|
|
}
|
|
},
|
|
{
|
|
processing: {
|
|
equals: false
|
|
}
|
|
},
|
|
{
|
|
'input.doc.value': {
|
|
equals: id
|
|
}
|
|
},
|
|
{
|
|
'input.doc.relationTo': {
|
|
equals: slug
|
|
}
|
|
},
|
|
// data.type narrows scheduled publish jobs in case of another job having input.doc.value
|
|
{
|
|
taskSlug: {
|
|
equals: 'schedulePublish'
|
|
}
|
|
}
|
|
]
|
|
}
|
|
});
|
|
} catch (err) {
|
|
payload.logger.error({
|
|
err,
|
|
msg: `There was an error deleting scheduled publish jobs from the queue for ${slug} document with ID ${id}.`
|
|
});
|
|
}
|
|
};
|
|
|
|
//# sourceMappingURL=deleteScheduledPublishJobs.js.map |