]> git.ipfire.org Git - pbs.git/commitdiff
jobs: Migrate from arch_id to arch
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 8 Oct 2017 11:53:13 +0000 (12:53 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 8 Oct 2017 11:53:13 +0000 (12:53 +0100)
Fixes #11497

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/buildservice/builds.py
src/templates/jobs-buildroot.html
src/templates/jobs-detail.html
src/templates/modules/jobs-table.html
src/templates/modules/jobs/boxes.html
src/templates/modules/jobs/list.html
src/templates/package-detail.html
src/templates/packages/view-file.html
src/templates/repository-detail.html

index f00de9c32dd04052a69c66aeff3d86b684efe8e5..17b38a56201041d64c986cd19790d2ffa5e622d8 100644 (file)
@@ -21,6 +21,7 @@ from . import updates
 from . import users
 
 from .constants import *
+from .decorators import *
 
 def import_from_package(_pakfire, filename, distro=None, commit=None, type="release",
                arches=None, check_for_duplicates=True, owner=None):
@@ -216,21 +217,21 @@ class Builds(base.Object):
                        WHERE NOT EXISTS \
                                (SELECT * FROM jobs WHERE \
                                        jobs.build_id = builds.id AND \
-                                       jobs.arch_id = %s AND \
+                                       jobs.arch = %s AND \
                                        (jobs.state != 'finished' OR \
                                        jobs.time_finished >= %s) \
                                ) \
                        AND EXISTS \
                                (SELECT * FROM jobs WHERE \
                                        jobs.build_id = builds.id AND \
-                                       jobs.arch_id = %s AND \
+                                       jobs.arch = %s AND \
                                        jobs.type = 'build' AND \
                                        jobs.state = 'finished' AND \
                                        jobs.time_finished < %s \
                                ) \
                        AND builds.type = 'release' \
                        AND (builds.state = 'stable' OR builds.state = 'testing')"
-               args  = [arch.id, threshold, arch.id, threshold]
+               args  = [arch, threshold, arch, threshold]
 
                if randomize:
                        query += " ORDER BY RAND()"
@@ -916,7 +917,7 @@ class Build(base.Object):
                s_jobs = []
                for job in self.jobs:
                        s_jobs.append("""<a class="state_%s %s" href="/job/%s">%s</a>""" % \
-                               (job.state, job.type, job.uuid, job.arch.name))
+                               (job.state, job.type, job.uuid, job.arch))
 
                if s_jobs:
                        s += " [%s]" % ", ".join(s_jobs)
@@ -1455,8 +1456,8 @@ class Jobs(base.Object):
                where = ["(state = 'finished' OR state = 'failed' OR state = 'aborted')"]
 
                if arch:
-                       where.append("arch_id = %s")
-                       args.append(arch.id)
+                       where.append("arch = %s")
+                       args.append(arch)
 
                if builder:
                        where.append("builder_id = %s")
@@ -1621,8 +1622,8 @@ class Job(base.Object):
 
        @classmethod
        def create(cls, pakfire, build, arch, type="build"):
-               id = pakfire.db.execute("INSERT INTO jobs(uuid, type, build_id, arch_id, time_created) \
-                       VALUES(%s, %s, %s, %s, NOW())", "%s" % uuid.uuid4(), type, build.id, arch.id)
+               id = pakfire.db.execute("INSERT INTO jobs(uuid, type, build_id, arch, time_created) \
+                       VALUES(%s, %s, %s, %s, NOW())", "%s" % uuid.uuid4(), type, build.id, arch)
 
                job = Job(pakfire, id)
                job.log("created")
@@ -1776,7 +1777,7 @@ class Job(base.Object):
 
        @property
        def name(self):
-               return "%s-%s.%s" % (self.pkg.name, self.pkg.friendly_version, self.arch.name)
+               return "%s-%s.%s" % (self.pkg.name, self.pkg.friendly_version, self.arch)
 
        @property
        def size(self):
@@ -1878,16 +1879,13 @@ class Job(base.Object):
 
        builder = property(get_builder, set_builder)
 
-       @property
-       def arch_id(self):
-               return self.data.arch_id
-
        @property
        def arch(self):
-               if not hasattr(self, "_arch"):
-                       self._arch = self.pakfire.arches.get_by_id(self.arch_id)
+               return self.data.arch
 
-               return self._arch
+       @lazy_property
+       def _arch(self):
+               return self.backend.arches.get_by_name(self.arch)
 
        @property
        def duration(self):
@@ -1919,7 +1917,7 @@ class Job(base.Object):
                        Returns the estimated time and stddev, this job takes to finish.
                """
                # Get the average build time.
-               build_times = self.pakfire.builds.get_build_times_by_arch(self.arch.name,
+               build_times = self.pakfire.builds.get_build_times_by_arch(self.arch,
                        name=self.pkg.name)
 
                # If there is no statistical data, we cannot estimate anything.
@@ -2011,7 +2009,7 @@ class Job(base.Object):
                        i = 1
                        while True:
                                target_filename = os.path.join(target_dirname,
-                                       "test.%s.%s.%s.log" % (self.arch.name, i, self.tries))
+                                       "test.%s.%s.%s.log" % (self.arch, i, self.tries))
 
                                if os.path.exists(target_filename):
                                        i += 1
@@ -2019,7 +2017,7 @@ class Job(base.Object):
                                        break
                else:
                        target_filename = os.path.join(target_dirname,
-                               "build.%s.%s.log" % (self.arch.name, self.tries))
+                               "build.%s.%s.log" % (self.arch, self.tries))
 
                # Make sure the target directory exists.
                if not os.path.exists(target_dirname):
@@ -2049,7 +2047,7 @@ class Job(base.Object):
                pkg = packages.Package.open(self.pakfire, filename)
 
                # Move package to the build directory.
-               pkg.move(os.path.join(self.build.path, self.arch.name))
+               pkg.move(os.path.join(self.build.path, self.arch))
 
                # Attach the package to this job.
                self.db.execute("INSERT INTO jobs_packages(job_id, pkg_id) VALUES(%s, %s)",
@@ -2281,7 +2279,7 @@ class Job(base.Object):
 
                # Create a new pakfire instance with the configuration for
                # this build.
-               p = pakfire.PakfireServer(config=config, arch=self.arch.name)
+               p = pakfire.PakfireServer(config=config, arch=self.arch)
 
                # Try to solve the build dependencies.
                try:
index 3313012488a0989d35e57761109463577f152f70..4da26fd7f98e4eb5144d14d59d01b01849e5cbb6 100644 (file)
@@ -21,7 +21,7 @@
                        <span class="divider">/</span>
                </li>
                <li>
-                       <a href="/job/{{ job.uuid }}">{{ job.arch.name }}</a>
+                       <a href="/job/{{ job.uuid }}">{{ job.arch }}</a>
                        <span class="divider">/</span>
                </li>
                <li class="active">
index 1ce30a8899af89edf5538a40afabbe85487732a6..b75e433701c31c94911c3987b79218607fd43d4a 100644 (file)
@@ -21,7 +21,7 @@
                        <span class="divider">/</span>
                </li>
                <li class="active">
-                       <a href="/job/{{ job.uuid }}">{{ job.arch.name }}</a>
+                       <a href="/job/{{ job.uuid }}">{{ job.arch }}</a>
                </li>
        </ul>
 
index 95b9d96215bd12ff43aed8918c0d5b589888cc41..2453071864be25baa46d7b09ec05d960ad04f3c9 100644 (file)
@@ -12,7 +12,7 @@
                        {% for job in jobs %}
                                <tr>
                                        <td>
-                                               <a href="/job/{{ job.uuid }}">{{ job.arch.name }}</a>
+                                               <a href="/job/{{ job.uuid }}">{{ job.arch }}</a>
                                        </td>
                                        <td>
                                                {% if job.state == "new" %}
index 3e07016d304c9e26a2774d0d10d2f7741835a60e..3ee48eea428d17db7a788cf19c4c8d93df3fc177 100644 (file)
@@ -6,7 +6,7 @@
                                        {{ format_time(j.duration, shorter=True) }} &dash;
                                        {% module JobState(j) %}
                                </small>
-                               <a href="/job/{{ j.uuid }}">{{ j.arch.name }}</a>
+                               <a href="/job/{{ j.uuid }}">{{ j.arch }}</a>
                        </h4>
 
                        <ul class="unstyled">
index ee14ee8ec9d2d5223fe50cce694e6e18b94e58cb..cdc65a7a56fa704e38b309fe3557bf881fac34fe 100644 (file)
@@ -26,7 +26,7 @@
 
                                <td>
                                        <a href="/build/{{ job.build.uuid }}">
-                                               {{ job.build.name }}</a>.<a href="/job/{{ job.uuid }}">{{ job.arch.name }}</a>
+                                               {{ job.build.name }}</a>.<a href="/job/{{ job.uuid }}">{{ job.arch }}</a>
 
                                        {% if job.build.type == "scratch" %}
                                                <span class="label label-inverse pull-right" rel="tooltip" data-placement="top" title="{{ _("Scratch build") }}">S</span>
index d4238afee14090a4b12e52f53c2044970b4490a9..8d89a055d13611ef2926ee4775c33b498eaa9284 100644 (file)
@@ -24,7 +24,7 @@
                {% end %}
                {% if pkg.job %}
                        <li>
-                               <a href="/job/{{ pkg.job.uuid }}">{{ pkg.job.arch.name }}</a>
+                               <a href="/job/{{ pkg.job.uuid }}">{{ pkg.job.arch }}</a>
                                <span class="divider">/</span>
                        </li>
                {% end %}
index b6d70a9b678e26d15d699019c21032191b2d3330..ba5b53c6ce7c4f39e9b7542a01d577e364769d6b 100644 (file)
@@ -24,7 +24,7 @@
                {% end %}
                {% if pkg.job %}
                        <li>
-                               <a href="/job/{{ pkg.job.uuid }}">{{ pkg.job.arch.name }}</a>
+                               <a href="/job/{{ pkg.job.uuid }}">{{ pkg.job.arch }}</a>
                                <span class="divider">/</span>
                        </li>
                {% end %}
index f4736e8253ccd61cc819e612ee747b107499d508..4a4db0aeffa6a9c9998c5b8c80564216f7787961 100644 (file)
@@ -88,7 +88,7 @@
                                <tbody>
                                        {% for arch, build_time in build_times %}
                                                <tr>
-                                                       <td class="arch">{{ arch.name }}</td>
+                                                       <td class="arch">{{ arch }}</td>
                                                        <td class="time">{{ friendly_time(build_time) }}</td>
                                                </tr>
                                        {% end %}