Command.handle()   A
last analyzed

Complexity

Conditions 2

Size

Total Lines 11
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 11
rs 9.95
c 0
b 0
f 0
cc 2
nop 3
1
from django.core.management.base import BaseCommand
2
from ore.models import Job, Result
3
4
5
class Command(BaseCommand):
6
    help = 'Clear all finished jobs with cached results'
7
8
    def handle(self, *args, **options):
9
        finished_jobs = Job.objects.filter(exit_code=0)
10
        print "%u finished jobs are stored ..." % len(finished_jobs)
11
12
        for j in finished_jobs:
13
                print "Deleting cached results for job %u" + j.pk
14
                results = Result.objects.filter(job=j)
15
                results.delete()
16
17
        print "Deleting finished jobs ..."
18
        finished_jobs.delete()
19