summaryrefslogtreecommitdiffstats
path: root/pharos-dashboard/dashboard/tasks.py
blob: 3df4bfba264266bc8cc8c1feafae1fc8d76418dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
from celery import shared_task
from datetime import timedelta
from django.utils import timezone

from jenkins.models import JenkinsStatistic
from notification.models import BookingNotification


@shared_task
def database_cleanup():
    now = timezone.now()
    JenkinsStatistic.objects.filter(timestamp__lt=now - timedelta(weeks=4)).delete()
    BookingNotification.objects.filter(submit_time__lt=now - timedelta(weeks=4)).delete()