Speedup maintainer::objectGetEntries and maintainer::objectGetEntriesCount. Use UNION for sql

statements and multipage controls
This commit is contained in:
Alexander Nicolaysen Sørnes
2007-07-26 14:42:21 +00:00
committed by WineHQ
parent 93dc3e0396
commit f37fa6e42f

View File

@@ -165,7 +165,7 @@ class maintainer
var $sMaintainReason;
var $bSuperMaintainer;
var $aSubmitTime; //FIXME: should be 'sSubmitTime'
var $bQueued;
var $bQueued; //FIXME: Should be sQueued
var $sReplyText;
// parameters used in the queued data notification system
@@ -382,45 +382,75 @@ class maintainer
return $hResult;
}
function ObjectGetEntries($bQueued, $bRejected)
function ObjectGetEntries($bQueued, $bRejected, $iRows = 0, $iStart = 0)
{
/* Not implemented */
if($bRejected)
return FALSE;
$sLimit = "";
/* Should we add a limit clause to the query? */
if($iRows || $iStart)
{
$sLimit = " LIMIT ?,?";
/* Selecting 0 rows makes no sense, so we assume the user wants to select all of them
after an offset given by iStart */
if(!$iRows)
$iRows = maintainer::objectGetEntriesCount($bQueued, $bRejected);
}
/* Excluding requests for queued apps and versions, as these will be
handled automatically */
$sQuery = "SELECT DISTINCT appMaintainers.* FROM
appMaintainers, appFamily, appVersion WHERE
$sQuery = "(SELECT DISTINCT appMaintainers.* FROM
appMaintainers, appFamily WHERE
appMaintainers.queued = '?'
AND
appFamily.appId = appVersion.appId
appMaintainers.superMaintainer = '1'
AND
(
(
appFamily.appId = appMaintainers.appId
AND
appFamily.queued = 'false'
AND
appMaintainers.versionId = ''
)
OR
(
appVersion.versionId = appMaintainers.versionId
AND
appVersion.queued = 'false'
)
)";
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";
if($bQueued)
{
if($_SESSION['current']->hasPriv("admin"))
return query_parameters($sQuery, $bQueued ? "true" : "false");
else
{
if($sLimit)
{
return query_parameters($sQuery, $bQueued ? "true" : "false",
$bQueued ? "true" : "false",
$iStart, $iRows);
} else
{
return query_parameters($sQuery, $bQueued ? "true" : "false",
$bQueued ? "true" : "false");
}
} else
{
return NULL;
}
} else
{
return query_parameters($sQuery, $bQueued ? "true" : "false");
if($sLimit)
{
return query_parameters($sQuery, $bQueued ? "true" : "false",
$bQueued ? "true" : "false", $iStart, $iRows);
} else
{
return query_parameters($sQuery, $bQueued ? "true" : "false",
$bQueued ? "true" : "false");
}
}
}
@@ -475,34 +505,33 @@ 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 queued_maintainers FROM
appMaintainers, appFamily, appVersion WHERE
appMaintainers.queued = '?'
AND
appFamily.appId = appVersion.appId
AND
(
(
appFamily.appId = appMaintainers.appId
AND
appFamily.queued = 'false'
AND
appMaintainers.versionId = ''
)
OR
(
appVersion.versionId = appMaintainers.versionId
AND
appVersion.queued = 'false'
)
)";
$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")))
if(!($hResult = query_parameters($sQuery, $bQueued ? "true" : "false",
$bQueued ? "true" : "false")))
return FALSE;
$oRow = mysql_fetch_object($hResult);
for($iCount = 0; $oRow = mysql_fetch_object($hResult);)
$iCount += $oRow->count;
return $oRow->queued_maintainers;
return $iCount;
}
/* see how many maintainer entries we have in the database */
@@ -782,6 +811,13 @@ class maintainer
return TRUE;
}
function objectGetItemsPerPage($bQueued = false)
{
$aItemsPerPage = array(25, 50, 100, 200);
$iDefaultPerPage = 25;
return array($aItemsPerPage, $iDefaultPerPage);
}
function update()
{
/* STUB: No updating possible at the moment */