Let's take a look at an example of a scheduled job from our Give & Get site (template).Â
On our site, we use a scheduled job to remove giveaways that were either added or last updated over two months ago.Â
The job configuration looks like this:
As you can see the job is configured to call the removeOldGiveaways()
function from giveawaysModule.jsw once a day at 8:00 in the morning UTC time.
The removeOldGiveaways()
function looks like this:
We begin by calculating the date of the day that occurred two months ago.Â
Then, we find the giveaways that are older than two months old.
Next, we extract the IDs from the old giveaways. We need these to delete them.
Finally, we remove all the old giveaways using the bulk removal operation.