Add unit tests
[pharos.git] / tools / pharos-dashboard / src / dashboard / tasks.py
1 ##############################################################################
2 # Copyright (c) 2016 Max Breitenfeldt and others.
3 #
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
9
10
11 from datetime import timedelta
12
13 from celery import shared_task
14 from django.utils import timezone
15
16 from jenkins.models import JenkinsStatistic
17 from notification.models import BookingNotification
18
19
20 @shared_task
21 def database_cleanup():
22     now = timezone.now()
23     JenkinsStatistic.objects.filter(timestamp__lt=now - timedelta(weeks=4)).delete()
24     BookingNotification.objects.filter(submit_time__lt=now - timedelta(weeks=4)).delete()