help
help copied to clipboard
How to create an automatic closing ticket job ?
- Node.js Version: v14.15.1
- OS: Mac
- Scope (install, code, runtime, meta, other?): Code
- Module (and version) (if relevant): mongoose (^5.11.2); Express (^4.17.1)
Hello everyone !
I have been facing a problem for a few days. I am in the process of building a support ticket system. I have a template for my tickets created with mongoose (name, status, assigned to, ...). The problem is as follows: Make sure that tickets that have not been processed for more than 15 days are automatically closed or present an alert.
How could I check the status of a ticket every X days and then update its status when it has been inactive for more than X days.
I would appreciate any help from you!
Have a good day !
may be like:
setInterval(() => {
// your check and purge logic goes here.
}, 15 * 24 * 60 * 60 * 1000)
? (where the interval count is 15 days in millis, which is the unit of time the API expects)
Save Tickets in the database, and add the last update field. In the Node.js code, define a timed task to query the database at 0:00 every day for Tickets that were last updated > 15 days ago, and then close it.
You can use node-cron to define scheduled tasks.
Save Tickets in the database, and add the last update field. In the Node.js code, define a timed task to query the database at 0:00 every day for Tickets that were last updated > 15 days ago, and then close it.
You can use node-cron to define scheduled tasks.
That is a good solution, could you give me a n example for this solution ?
may be like:
setInterval(() => { // your check and purge logic goes here. }, 15 * 24 * 60 * 60 * 1000)? (where the interval count is 15 days in millis, which is the unit of time the API expects)
Thank you ! I've already tried setTimeout and setInterval, wasn't the good way in my opinion..😢
Save Tickets in the database, and add the last update field. In the Node.js code, define a timed task to query the database at 0:00 every day for Tickets that were last updated > 15 days ago, and then close it. You can use node-cron to define scheduled tasks.
That is a good solution, could you give me a n example for this solution ?
There are no existing examples, you need to select the database and implement this part of the logic yourself. Don't worry, it's easy to implement.
It seems there has been no activity on this issue for a while, and it is being closed in 30 days. If you believe this issue should remain open, please leave a comment. If you need further assistance or have questions, you can also search for similar issues on Stack Overflow. Make sure to look at the README file for the most updated links.
It seems there has been no activity on this issue for a while, and it is being closed. If you believe this issue should remain open, please leave a comment. If you need further assistance or have questions, you can also search for similar issues on Stack Overflow. Make sure to look at the README file for the most updated links.