help icon indicating copy to clipboard operation
help copied to clipboard

How to create an automatic closing ticket job ?

Open mattpilleul opened this issue 4 years ago • 6 comments

  • 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 !

mattpilleul avatar Dec 03 '20 19:12 mattpilleul

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)

gireeshpunathil avatar Dec 04 '20 04:12 gireeshpunathil

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.

Lxxyx avatar Dec 04 '20 05:12 Lxxyx

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 ?

mattpilleul avatar Dec 04 '20 08:12 mattpilleul

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..😢

mattpilleul avatar Dec 04 '20 08:12 mattpilleul

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.

Lxxyx avatar Dec 04 '20 09:12 Lxxyx

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.

github-actions[bot] avatar May 10 '24 01:05 github-actions[bot]

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.

github-actions[bot] avatar Jun 09 '24 01:06 github-actions[bot]