ore.management.commands.clearresultcache   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 14
dl 0
loc 19
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A Command.handle() 0 11 2
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