-
Notifications
You must be signed in to change notification settings - Fork 340
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a settings variable to allow configurable time periods for noti…
…fication deletion (#2547) Added NOTIFICATION_RETENTION_DAYS settings variable to allow configurable time period with default of 30 days
- Loading branch information
Showing
3 changed files
with
11 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,15 @@ | ||
from datetime import timedelta | ||
|
||
from celery import shared_task | ||
from django.conf import settings | ||
from django.utils import timezone | ||
|
||
from care.facility.models.notification import Notification | ||
|
||
|
||
@shared_task | ||
def delete_old_notifications(): | ||
ninety_days_ago = timezone.now() - timedelta(days=90) | ||
Notification.objects.filter(created_date__lte=ninety_days_ago).delete() | ||
retention_days = settings.NOTIFICATION_RETENTION_DAYS | ||
|
||
threshold_date = timezone.now() - timedelta(days=retention_days) | ||
Notification.objects.filter(created_date__lte=threshold_date).delete() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters