Tivix / django-cron

Write cron business logic as a Python class and let this app do the rest! It enables Django projects to schedule cron tasks, tracks their success / failures, manages contention (via a cache) etc. Basically takes care of all the boring work for you :-)
www.tivix.com
MIT License
899 stars 192 forks source link

Improve the FailedRunsNotificationCronJob to be more resilient #107

Open evenicoulddoit opened 7 years ago

evenicoulddoit commented 7 years ago

In it's existing setup, the FailedRunsNotificationCronJob simply sends an email when the number of failed runs for a certain job reaches a pre-determined level (which defaults to 10). After this point (i.e. at fail 11, 12...) the user will not receive any further emails.

Furthermore, the job will also continue to send emails to the users every time the runcrons task is called, provided the number of failed runs remains at the level which triggers the email. Therefore, if you're using crontab e.g. to run the runcrons management command every 10 minutes, the user will be emailed about the failure every 10 minutes.

101 aims to fix both problems. By adding a failure_reported flag to the CronJobLog model, Once the number of failures exceeds the user determined limit, they are marked as having been notified.

In addition to the above, a few changes are made to:

Tests are provided and documentation has been added

tab-cmd commented 7 years ago

@evenicoulddoit thanks, will review shortly 👍