Alexander Nicolaysen Sørnes : maintainer : Simplify SQL code

Chris Morgan cmorgan at winehq.org
Tue Nov 6 23:23:33 CST 2007


Module: appdb
Branch: master
Commit: b3e71b0a8137846039ead71a57f9b4a6b97d77c1
URL:    http://source.winehq.org/git/appdb.git/?a=commit;h=b3e71b0a8137846039ead71a57f9b4a6b97d77c1

Author: Alexander Nicolaysen Sørnes <alex at thehandofagony.com>
Date:   Tue Nov  6 15:29:58 2007 +0100

maintainer: Simplify SQL code

---

 include/maintainer.php |   64 ++++++++++-------------------------------------
 1 files changed, 14 insertions(+), 50 deletions(-)

diff --git a/include/maintainer.php b/include/maintainer.php
index c3d64aa..e7d2b47 100644
--- a/include/maintainer.php
+++ b/include/maintainer.php
@@ -410,24 +410,8 @@ class maintainer
 
         /* Excluding requests for queued apps and versions, as these will be
            handled automatically */
-        $sQuery = "(SELECT DISTINCT appMaintainers.* FROM 
-            appMaintainers, appFamily WHERE
-            appMaintainers.queued = '?'
-            AND
-            appMaintainers.superMaintainer = '1'
-            AND
-            appFamily.appId = appMaintainers.appId
-            AND
-            appFamily.queued = 'false') UNION
-            (SELECT DISTINCT appMaintainers.* FROM
-            appMaintainers, appVersion WHERE
-            appMaintainers.queued = '?'
-            AND
-            appMaintainers.versionId = appVersion.versionId
-            AND
-            appMaintainers.superMaintainer = '0'
-            AND
-            appVersion.queued = 'false')$sLimit";
+        $sQuery = "SELECT * FROM appMaintainers WHERE
+            appMaintainers.queued = '?'$sLimit";
 
         if($bQueued)
         {
@@ -435,13 +419,10 @@ class maintainer
             {
                 if($sLimit)
                 {
-                    return query_parameters($sQuery, $bQueued ? "true" : "false",
-                                            $bQueued ? "true" : "false",
-                                            $iStart, $iRows);
+                    return query_parameters($sQuery, $bQueued ? "true" : "false", $iStart, $iRows);
                 } else
                 {
-                    return query_parameters($sQuery, $bQueued ? "true" : "false",
-                                            $bQueued ? "true" : "false");
+                    return query_parameters($sQuery, $bQueued ? "true" : "false");
                 }
             } else
             {
@@ -451,12 +432,10 @@ class maintainer
         {
             if($sLimit)
             {
-                return query_parameters($sQuery, $bQueued ? "true" : "false",
-                                        $bQueued ? "true" : "false", $iStart, $iRows);
+                return query_parameters($sQuery, $bQueued ? "true" : "false", $iStart, $iRows);
             } else
             {
-                return query_parameters($sQuery, $bQueued ? "true" : "false",
-                                        $bQueued ? "true" : "false");
+                return query_parameters($sQuery, $bQueued ? "true" : "false");
             }
         }
     }
@@ -512,31 +491,16 @@ class maintainer
 
         /* Excluding requests for queued apps and versions, as these are handled 
            automatically.  One SELECT for super maintainers, one for maintainers. */
-       $sQuery = "(SELECT COUNT(DISTINCT maintainerId) as count FROM 
-            appMaintainers, appFamily WHERE
-            appMaintainers.queued = '?'
-            AND
-            appMaintainers.superMaintainer = '1'
-            AND
-            appFamily.appId = appMaintainers.appId
-            AND
-            appFamily.queued = 'false') UNION
-            (SELECT COUNT(DISTINCT maintainerId) as count FROM
-            appMaintainers, appVersion WHERE
-            appMaintainers.queued = '?'
-            AND
-            appMaintainers.versionId = appVersion.versionId
-            AND
-            appMaintainers.superMaintainer = '0'
-            AND
-            appVersion.queued = 'false')";
-
-        if(!($hResult = query_parameters($sQuery, $bQueued ? "true" : "false",
-                                         $bQueued ? "true" : "false")))
+       $sQuery = "SELECT COUNT(maintainerId) as count FROM appMaintainers WHERE
+            appMaintainers.queued = '?'";
+
+        if(!($hResult = query_parameters($sQuery, $bQueued ? "true" : "false")))
             return FALSE;
 
-        for($iCount = 0; $oRow = query_fetch_object($hResult);)
-            $iCount += $oRow->count;
+        if($oRow = query_fetch_object($hResult))
+            $iCount = $oRow->count;
+        else
+            $iCount = 0;
 
         return $iCount;
     }




More information about the wine-cvs mailing list