I’ve watched the video on how to schedule a timed task to clean old [listings.](listings.
https://www.wix.com/corvid/forum/tips-tutorials-examples/video-how-to-execute-timed-tasks-with-the-job-scheduler)
However this is set to occur every 3 months and I want to have this happen weekly.
https://www.sloungebar.com.au/gigguidetest
Any help appreciated as I can’t seem to get this to happen weekly.
Thank you
BACKEND MODULE
import wixData from ‘wix-data’ ;
export function clearOldListings() {
// Querying all the items in the collection.
return wixData.query( “GigList” ).find().then(results => {
// Declaring a variable for an expiration date to test by initiating it as a date object.
let expirationDate = new Date();
// Setting the expiration date for 3 months prior.
expirationDate.setWeek(expirationDate.getWeek() - 1 );
// Using the forEach method to create a filtered array with listings older than 3 months.
let oldListings = results.items.filter(item => item.uploadedOn < expirationDate);
oldListings.forEach(item => {
// Removing each of this items from the collection.
wixData.remove( “GigList” , item._id);
})
})
}
JOB SCHEDULER
{
“jobs” : [{
“functionLocation” : “/DatabaseJobs.clearOldListings” ,
“description” : “Clear Weekly-onMonday” ,
“executionConfig” : {
“time” : “20:40” ,
“dayOfWeek” : Sunday
}
}
]
}