diff --git a/cross-reference/crossreference/cr/models.py b/cross-reference/crossreference/cr/models.py index 551e4b06..31588739 100644 --- a/cross-reference/crossreference/cr/models.py +++ b/cross-reference/crossreference/cr/models.py @@ -5,6 +5,16 @@ from django.db import connection from datetime import datetime +class Builder(models.Model): + id = models.IntegerField(primary_key=True) + name = models.TextField() + description = models.TextField(null=True, blank=True) + name_hash = models.CharField(max_length=40, unique=True) + + class Meta: + managed = False + db_table = 'builders' + class TestRun(models.Model): branch = models.CharField(max_length=100, blank=True, null=True) revision = models.CharField(max_length=256, blank=True, null=True) @@ -14,6 +24,11 @@ class TestRun(models.Model): typ = models.CharField(max_length=32) info = models.CharField(max_length=255, blank=True, null=True) + @property + def platform_name(self): + builder = Builder.objects.filter(name=self.platform).first() + return builder.id if builder else None + class Meta: managed = False db_table = 'test_run' diff --git a/cross-reference/crossreference/cr/router.py b/cross-reference/crossreference/cr/router.py index 8fdbcee1..e5ea1b3e 100644 --- a/cross-reference/crossreference/cr/router.py +++ b/cross-reference/crossreference/cr/router.py @@ -1,4 +1,4 @@ -from .models import TestRun, TestFailure +from .models import TestRun, TestFailure, Builder class MariaDBRouter: """ @@ -6,7 +6,7 @@ class MariaDBRouter: """ def db_for_read(self, model, **hints): - if model in [TestRun, TestFailure]: + if model in [TestRun, TestFailure, Builder]: return 'mariadb' return 'default' diff --git a/cross-reference/crossreference/cr/templates/cr/index.html b/cross-reference/crossreference/cr/templates/cr/index.html index a9993824..90ee4581 100644 --- a/cross-reference/crossreference/cr/templates/cr/index.html +++ b/cross-reference/crossreference/cr/templates/cr/index.html @@ -91,7 +91,7 @@