]> git.ipfire.org Git - pbs.git/commitdiff
builds: Drop various deprecated stuff
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 28 Jun 2022 15:36:10 +0000 (15:36 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 28 Jun 2022 15:36:10 +0000 (15:36 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/buildservice/builds.py
src/database.sql

index daf641c0542b46556ba0d3ff6561cc314e13fad9..e4089f83c9ccae895b07ae1477d5178b213d7784 100644 (file)
@@ -275,12 +275,6 @@ class Build(base.DataObject):
 
                return NotImplemented
 
-       def __iter__(self):
-               jobs = self.backend.jobs._get_jobs("SELECT * FROM jobs \
-                       WHERE build_id = %s", self.id)
-
-               return iter(sorted(jobs))
-
        def delete(self):
                """
                        Deletes this build including all jobs,
@@ -319,13 +313,6 @@ class Build(base.DataObject):
                # Delete source package
                self.pkg.delete()
 
-       @property
-       def info(self):
-               """
-                       A set of information that is sent to the XMLRPC client.
-               """
-               return { "uuid" : self.uuid }
-
        def log(self, action, user=None, bug_id=None):
                user_id = None
                if user:
@@ -371,10 +358,7 @@ class Build(base.DataObject):
                        return self.backend.users.get_by_id(self.data.owner_id)
 
        def set_owner(self, owner):
-               if owner:
-                       self._set_attribute("owner_id", owner.id)
-               else:
-                       self._set_attribute("owner_id", None)
+               self._set_attribute("owner_id", owner)
 
        owner = lazy_property(get_owner, set_owner)
 
@@ -382,44 +366,10 @@ class Build(base.DataObject):
        def distro(self):
                return self.backend.distros.get_by_id(self.data.distro_id)
 
-       @property
-       def user(self):
-               if self.type == "scratch":
-                       return self.owner
-
-       def get_depends_on(self):
-               if self.data.depends_on:
-                       return self.backend.builds.get_by_id(self.data.depends_on)
-
-       def set_depends_on(self, build):
-               self._set_attribute("depends_on", build.id)
-
-       depends_on = lazy_property(get_depends_on, set_depends_on)
-
        @property
        def created(self):
                return self.data.time_created
 
-       @property
-       def date(self):
-               return self.created.date()
-
-       @lazy_property
-       def size(self):
-               """
-                       Returns the size on disk of this build.
-               """
-               s = 0
-
-               # Add the source package.
-               if self.pkg:
-                       s += self.pkg.size
-
-               # Add all jobs.
-               s += sum((j.size for j in self.jobs))
-
-               return s
-
        def auto_update_state(self):
                """
                        Check if the state of this build can be updated and perform
@@ -563,23 +513,6 @@ class Build(base.DataObject):
 
        priority = property(get_priority, set_priority)
 
-       @property
-       def link(self):
-               # XXX maybe this should rather live in a uimodule.
-               # zlib-1.2.3-2.ip3 [src, i686, blah...]
-               s = """<a class="state_%s %s" href="/build/%s">%s</a>""" % \
-                       (self.state, self.type, self.uuid, self.name)
-
-               s_jobs = []
-               for job in self.jobs:
-                       s_jobs.append("""<a class="state_%s %s" href="/job/%s">%s</a>""" % \
-                               (job.state, "test" if job.test else "build", job.uuid, job.arch))
-
-               if s_jobs:
-                       s += " [%s]" % ", ".join(s_jobs)
-
-               return s
-
        @property
        def supported_arches(self):
                return self.pkg.supported_arches
@@ -648,42 +581,6 @@ class Build(base.DataObject):
                for arch in arches:
                        self.backend.jobs.create(self, arch)
 
-       ## Update stuff
-
-       @property
-       def update_id(self):
-               if not self.type == "release":
-                       return
-
-               # Generate an update ID if none does exist, yet.
-               self.generate_update_id()
-
-               s = [
-                       "%s" % self.distro.name.replace(" ", "").upper(),
-                       "%04d" % (self.data.update_year or 0),
-                       "%04d" % (self.data.update_num or 0),
-               ]
-
-               return "-".join(s)
-
-       def generate_update_id(self):
-               if not self.type == "release":
-                       return
-
-               if self.data.update_num:
-                       return
-
-               update = self.db.get("SELECT update_num AS num FROM builds \
-                       WHERE update_year = EXTRACT(year FROM NOW()) ORDER BY update_num DESC LIMIT 1")
-
-               if update:
-                       update_num = update.num + 1
-               else:
-                       update_num = 1
-
-               self.db.execute("UPDATE builds SET update_year = EXTRACT(year FROM NOW()), update_num = %s \
-                       WHERE id = %s", update_num, self.id)
-
        ## Comment stuff
 
        def get_comments(self, limit=10, offset=0):
@@ -749,9 +646,6 @@ class Build(base.DataObject):
                if comments:
                        entries += self.get_comments(limit=limit)
 
-               if repo:
-                       entries += self.get_repo_moves(limit=limit)
-
                # Sort all entries in chronological order.
                entries.sort()
 
@@ -787,17 +681,6 @@ class Build(base.DataObject):
 
                return ret
 
-       @property
-       def update(self):
-               if self._update is None:
-                       update = self.db.get("SELECT update_id AS id FROM updates_builds \
-                               WHERE build_id = %s", self.id)
-
-                       if update:
-                               self._update = updates.Update(self.backend, update.id)
-
-               return self._update
-
        @lazy_property
        def repo(self):
                res = self.db.get("SELECT repo_id FROM repositories_builds \
@@ -806,24 +689,6 @@ class Build(base.DataObject):
                if res:
                        return self.backend.repos.get_by_id(res.repo_id)
 
-       def get_repo_moves(self, limit=None):
-               query = "SELECT * FROM repositories_history \
-                       WHERE build_id = %s ORDER BY time ASC"
-
-               actions = []
-               for action in self.db.query(query, self.id):
-                       action = logs.RepositoryLogEntry(self.backend, action)
-                       actions.append(action)
-
-               return actions
-
-       @property
-       def is_loose(self):
-               if self.repo:
-                       return False
-
-               return True
-
        @property
        def repo_time(self):
                repo = self.db.get("SELECT time_added FROM repositories_builds \
@@ -832,37 +697,6 @@ class Build(base.DataObject):
                if repo:
                        return repo.time_added
 
-       def get_auto_move(self):
-               return self.data.auto_move == "Y"
-
-       def set_auto_move(self, state):
-               self._set_attribute("auto_move", state)
-
-       auto_move = property(get_auto_move, set_auto_move)
-
-       @property
-       def can_move_forward(self):
-               if not self.repo:
-                       return False
-
-               # If there is no next repository, we cannot move anything.
-               if not self.repo.__next__:
-                       return False
-
-               # If the needed amount of score is reached, we can move forward.
-               if self.score >= self.repo.next.score_needed:
-                       return True
-
-               # If the repository does not require a minimal time,
-               # we can move forward immediately.
-               if not self.repo.time_min:
-                       return True
-
-               query = self.db.get("SELECT NOW() - time_added AS duration FROM repositories_builds \
-                       WHERE build_id = %s", self.id)
-
-               return query.duration.total_seconds() >= self.repo.time_min
-
        ## Bugs
 
        def get_bug_ids(self):
index f986b18a5e5f903a5ff02e4237fd9838692327c3..331d14411d93a7d1e22f61631445c205ae724b2a 100644 (file)
@@ -174,13 +174,9 @@ CREATE TABLE public.builds (
     severity text,
     message text,
     time_created timestamp without time zone DEFAULT now() NOT NULL,
-    update_year integer,
-    update_num integer,
-    depends_on integer,
     distro_id integer NOT NULL,
     owner_id integer,
     priority integer DEFAULT 0 NOT NULL,
-    auto_move boolean DEFAULT false NOT NULL,
     deleted boolean DEFAULT false NOT NULL
 );
 
@@ -2345,14 +2341,6 @@ ALTER TABLE ONLY public.builds_comments
     ADD CONSTRAINT builds_comments_user_id FOREIGN KEY (user_id) REFERENCES public.users(id);
 
 
---
--- Name: builds builds_depends_on; Type: FK CONSTRAINT; Schema: public; Owner: pakfire
---
-
-ALTER TABLE ONLY public.builds
-    ADD CONSTRAINT builds_depends_on FOREIGN KEY (depends_on) REFERENCES public.builds(id);
-
-
 --
 -- Name: builds builds_distro_id; Type: FK CONSTRAINT; Schema: public; Owner: pakfire
 --