commit 41e6ca3fbe9e148b7628c86aa908044bc7d443ec
Author: Matthias Kretz <kretz@kde.org>
Date:   Tue May 22 15:04:42 2012 +0200

    fix error/warnings count if multiple sub-builds are submitted for a whole build

diff --git a/models/build.php b/models/build.php
index 593b6fb..fda064b 100644
--- a/models/build.php
+++ b/models/build.php
@@ -550,10 +550,10 @@ class Build
         $this->Log = pdo_real_escape_string(' '.$this->Log);
 
         // Compute the number of errors and warnings (this speeds up the display of the main table)
+        $nbuilderrors = 0;
+        $nbuildwarnings = 0;
         if($this->InsertErrors)
           {
-          $nbuilderrors = 0;
-          $nbuildwarnings = 0;
           foreach($this->Errors as $error)
             {
             if($error->Type == 0)
@@ -566,18 +566,14 @@ class Build
               }
             }
           }
-        else
-          {
-          $nbuilderrors = -1;
-          $nbuildwarnings = -1;
-          }
 
         include('cdash/config.php');
         if($CDASH_DB_TYPE == 'pgsql') // pgsql doesn't have concat...
           {
           $query = "UPDATE build SET
                   endtime='$this->EndTime',submittime='$this->SubmitTime',
-                  builderrors='$nbuilderrors',buildwarnings='$nbuildwarnings'," .
+                  builderrors=(CASE WHEN builderrors < 0 THEN 0 ELSE builderrors END)+'$nbuilderrors',
+                  buildwarnings=(CASE WHEN buildwarnings < 0 THEN 0 ELSE buildwarnings END)+'$nbuildwarnings'," .
                   "command=command || '$this->Command',
                   log=log || '$this->Log'" .
           "WHERE id=".qnum($this->Id);
@@ -586,7 +582,8 @@ class Build
           {
           $query = "UPDATE build SET
                   endtime='$this->EndTime',submittime='$this->SubmitTime',
-                  builderrors='$nbuilderrors',buildwarnings='$nbuildwarnings'," .
+                  builderrors=(CASE WHEN builderrors < 0 THEN 0 ELSE builderrors END)+'$nbuilderrors',
+                  buildwarnings=(CASE WHEN buildwarnings < 0 THEN 0 ELSE buildwarnings END)+'$nbuildwarnings'," .
                   "command=CONCAT(command, '$this->Command'),
                   log=CONCAT(log, '$this->Log')" .
           "WHERE id=".qnum($this->Id);
