| from django.db import models |
from django.db import models |
| from django.contrib.auth.models import User |
from django.contrib.auth.models import User |
| |
from lkrtweb.lkrt.helpers import db |
| |
from django.core.exceptions import ObjectDoesNotExist |
| |
|
| import os |
import os |
| |
|
| super(KernelVersion, self).save() |
super(KernelVersion, self).save() |
| |
|
| def status_for_arch(self, arch): |
def status_for_arch(self, arch): |
| tests = FunctionalTest.objects.filter(kversion__id=self.id, client__arch__id=arch.id) |
objs = db.query('''SELECT max(status_id) as status_id |
| |
FROM $FunctionalTest$, $ClientMachine$ |
| |
WHERE $FunctionalTest$.client_id = $ClientMachine$.id |
| |
AND $ClientMachine$.arch_id=%s |
| |
AND $FunctionalTest$.kversion_id=%s''' % (arch.id, self.id)) |
| |
|
| |
stat = None |
| |
|
| |
if objs[0][0] != None: |
| |
try: |
| |
stat = Status.objects.get(id=objs[0][0]) |
| |
except ObjectDoesNotExist: |
| |
pass |
| |
|
| if tests.count() > 0: |
return stat |
| val = 0 |
|
| for test in tests: |
|
| val = max(val, test.status_id) |
|
| result = Status.objects.get(id=val) |
|
| else: |
|
| result = None |
|
| |
|
| return result |
# tests = FunctionalTest.objects.filter(kversion__id=self.id, client__arch__id=arch.id) |
| |
# |
| |
# if tests.count() > 0: |
| |
# val = 0 |
| |
# for test in tests: |
| |
# val = max(val, test.status_id) |
| |
# result = Status.objects.get(id=val) |
| |
# else: |
| |
# result = None |
| |
# |
| |
# return result |
| |
|
| def add_patch_at_url(self, url): |
def add_patch_at_url(self, url): |
| patch, created = File.objects.get_or_create(url=url) |
patch, created = File.objects.get_or_create(url=url) |