Add license headers
[pharos.git] / tools / pharos-dashboard / 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 celery import shared_task
12 from datetime import timedelta
13 from django.utils import timezone
14
15 from jenkins.models import JenkinsStatistic
16 from notification.models import BookingNotification
17
18
19 @shared_task
20 def database_cleanup():
21     now = timezone.now()
22     JenkinsStatistic.objects.filter(timestamp__lt=now - timedelta(weeks=4)).delete()
23     BookingNotification.objects.filter(submit_time__lt=now - timedelta(weeks=4)).delete()