Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 37 additions & 32 deletions cron-task.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,41 @@
module.exports = {
"*/30 * * * *": async ({ strapi }) => {
const posts = await strapi.db
.query("plugin::scheduler.scheduler")
.findMany({ where: { scheduledDatetime: { $lte: new Date() } } });

posts.map(async (post) => {
if (post.scheduleType === "schedule") {

await strapi.db.query(post.uid).update({
where: {
id: post.contentId,
},
data: {
publishedAt: new Date(),
},
});
await strapi.db
webbioSchedulerCron: {
options: {
rule: "*/30 * * * *",
},
task: async ({ strapi }) => {
const posts = await strapi.db
.query("plugin::scheduler.scheduler")
.delete({ where: { id: post.id } });
} else if (post.scheduleType === "depublish") {
await strapi.db.query(post.uid).update({
where: {
id: post.contentId,
},
data: {
publishedAt: null,
},
.findMany({ where: { scheduledDatetime: { $lte: new Date() } } });

posts.map(async (post) => {
if (post.scheduleType === "schedule") {

await strapi.db.query(post.uid).update({
where: {
id: post.contentId,
},
data: {
publishedAt: new Date(),
},
});
await strapi.db
.query("plugin::scheduler.scheduler")
.delete({ where: { id: post.id } });
} else if (post.scheduleType === "depublish") {
await strapi.db.query(post.uid).update({
where: {
id: post.contentId,
},
data: {
publishedAt: null,
},
});
await strapi.db
.query("plugin::scheduler.scheduler")
.delete({ where: { id: post.id } });
}
});
await strapi.db
.query("plugin::scheduler.scheduler")
.delete({ where: { id: post.id } });
}
});
},
},
}
};