]> git.ipfire.org Git - pbs.git/commitdiff
Upvote builds when it has testers
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 27 Oct 2017 15:40:33 +0000 (16:40 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 27 Oct 2017 15:45:26 +0000 (16:45 +0100)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/buildservice/builds.py
src/buildservice/sources.py
src/database.sql

index 061089c7d4baf480b57b49226965a4690ed3c321..5da249b37d31943a9e94f468f9e8534e306f188f 100644 (file)
@@ -843,6 +843,14 @@ class Build(base.DataObject):
 
                return res.score or 0
 
+       def upvote(self, user, score=1):
+               # Creates an empty comment with a score
+               self.db.execute("INSERT INTO builds_comments(build_id, user_id, score) \
+                       VALUES(%s, %s, %s)", self.id, user.id, score)
+
+               # Update cache
+               self.score += score
+
        def get_commenters(self):
                users = self.db.query("SELECT DISTINCT users.id AS id FROM builds_comments \
                        JOIN users ON builds_comments.user_id = users.id \
index b78512826f53f1b572f2cc21a0311874a51c9521..09e6cd7e6ef73e3b331902b617f30edf37095c22 100644 (file)
@@ -133,9 +133,13 @@ class Sources(base.Object):
                                                                # Import all packages in one swoop.
                                                                for pkg in pkgs:
                                                                        with self.db.transaction():
-                                                                               self.backend.builds.create_from_source_package(pkg,
+                                                                               build = self.backend.builds.create_from_source_package(pkg,
                                                                                        source.distro, commit=commit, type="release")
 
+                                                                               # Import any testers from the commit message
+                                                                               for tester in commit.testers:
+                                                                                       build.upvote(tester)
+
                                                        except:
                                                                if commit:
                                                                        commit.state = "failed"
@@ -287,6 +291,15 @@ class Commit(base.DataObject):
 
                return sorted(contributors + users)
 
+       @lazy_property
+       def testers(self):
+               users = []
+
+               for tag in ("Acked-by", "Reviewed-by", "Signed-off-by", "Tested-by"):
+                       users += self.get_tag(tag)
+
+               return self.backend.users.find_maintainers(users)
+
        @property
        def date(self):
                return self.data.date
index 7b34ea5eccca154b8d040a242025e7f07c8389bb..ef30b33ca547bbeba05fa1541d31ca7437b14f5d 100644 (file)
@@ -513,9 +513,9 @@ CREATE TABLE builds_comments (
     id integer NOT NULL,
     build_id integer NOT NULL,
     user_id integer NOT NULL,
-    text text NOT NULL,
+    text text,
     score integer NOT NULL,
-    time_created timestamp without time zone NOT NULL,
+    time_created timestamp without time zone DEFAULT now() NOT NULL,
     time_updated timestamp without time zone
 );