appdb/include appData.php

WineHQ wineowner at wine.codeweavers.com
Mon May 28 15:10:49 CDT 2007


ChangeSet ID:	31144
CVSROOT:	/opt/cvs-commit
Module name:	appdb
Changes by:	wineowner at winehq.org	2007/05/28 15:10:49

Modified files:
	include        : appData.php 

Log message:
	Alexander Nicolaysen Sørnes <alex at thehandofagony.com>
	Speedup appData::objectGetEntriesCount() when selecting un-queued entries or we are an admin.

Patch: http://cvs.winehq.org/patch.py?id=31144

Old revision  New revision  Changes     Path
 1.18          1.19          +26 -16     appdb/include/appData.php

Index: appdb/include/appData.php
diff -u -p appdb/include/appData.php:1.18 appdb/include/appData.php:1.19
--- appdb/include/appData.php:1.18	28 May 2007 20:10:49 -0000
+++ appdb/include/appData.php	28 May 2007 20:10:49 -0000
@@ -203,45 +203,55 @@ class appData
                 $sQuery .= " AND type = '?'";
                 $hResult = query_parameters($sQuery, $_SESSION['current']->iUserId, 
                                             $sType);
-            } else {
+            } else
+            {
                 $hResult = query_parameters($sQuery, $_SESSION['current']->iUserId);
             }
         } else
         {
-            $sQuery = "SELECT COUNT(DISTINCT appData.id) as count FROM appData,
+            if($sQueued == "true" || $sQueued == "false")
+                $sAppDataQueued = " AND appData.queued = '$sQueued'";
+
+            if($sType)
+                $sSelectType = " AND type = '?'";
+
+            $sQuery = "(SELECT COUNT(DISTINCT appData.id) as count FROM appData,
                 appFamily, appVersion WHERE
                     appFamily.appId = appVersion.appId
                     AND
                     (
                         appData.appId = appFamily.appId
-                        OR
+                    )
+                    AND
+                    appVersion.queued = 'false'
+                    AND
+                    appFamily.queued = 'false'$sAppDataQueued$sSelectType) UNION
+                    (
+                    SELECT COUNT(DISTINCT appData.id) as count FROM appData,
+                appFamily, appVersion WHERE
+                    appFamily.appId = appVersion.appId
+                    AND
+                    (
                         appData.versionId = appVersion.versionId
                     )
                     AND
                     appVersion.queued = 'false'
                     AND
-                    appFamily.queued = 'false'";
-
-            if($sQueued == "true" || $sQueued == "false")
-                $sQuery .= " AND appData.queued = '$sQueued'";
-
+                    appFamily.queued = 'false'$sAppDataQueued$sSelectType)";
 
             if($sType)
-            {
-                $sQuery .= " AND type = '?'";
-                $hResult = query_parameters($sQuery, $sType);
-            } else
+                $hResult = query_parameters($sQuery, $sType, $sType);
+            else
                 $hResult = query_parameters($sQuery);
         }
 
         if(!$hResult)
             return FALSE;
 
-        if(!$oRow = mysql_fetch_object($hResult))
-            return FALSE;
-
-        return $oRow->count;
+        for($iCount = 0; $oRow = mysql_fetch_object($hResult);)
+            $iCount += $oRow->count;
 
+        return $iCount;
     }
 
     function objectGetHeader($sType)



More information about the wine-cvs mailing list