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 $sMaintainReason;
var $bSuperMaintainer; var $bSuperMaintainer;
var $aSubmitTime; //FIXME: should be 'sSubmitTime' var $aSubmitTime; //FIXME: should be 'sSubmitTime'
var $bQueued; var $bQueued; //FIXME: Should be sQueued
var $sReplyText; var $sReplyText;
// parameters used in the queued data notification system // parameters used in the queued data notification system
@@ -382,45 +382,75 @@ class maintainer
return $hResult; return $hResult;
} }
function ObjectGetEntries($bQueued, $bRejected) function ObjectGetEntries($bQueued, $bRejected, $iRows = 0, $iStart = 0)
{ {
/* Not implemented */ /* Not implemented */
if($bRejected) if($bRejected)
return FALSE; 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 /* Excluding requests for queued apps and versions, as these will be
handled automatically */ handled automatically */
$sQuery = "SELECT DISTINCT appMaintainers.* FROM $sQuery = "(SELECT DISTINCT appMaintainers.* FROM
appMaintainers, appFamily, appVersion WHERE appMaintainers, appFamily WHERE
appMaintainers.queued = '?' appMaintainers.queued = '?'
AND AND
appFamily.appId = appVersion.appId appMaintainers.superMaintainer = '1'
AND AND
( appFamily.appId = appMaintainers.appId
( AND
appFamily.appId = appMaintainers.appId appFamily.queued = 'false') UNION
AND (SELECT DISTINCT appMaintainers.* FROM
appFamily.queued = 'false' appMaintainers, appVersion WHERE
AND appMaintainers.queued = '?'
appMaintainers.versionId = '' AND
) appMaintainers.versionId = appVersion.versionId
OR AND
( appMaintainers.superMaintainer = '0'
appVersion.versionId = appMaintainers.versionId AND
AND appVersion.queued = 'false')$sLimit";
appVersion.queued = 'false'
)
)";
if($bQueued) if($bQueued)
{ {
if($_SESSION['current']->hasPriv("admin")) 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; return NULL;
}
} else } 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 /* Excluding requests for queued apps and versions, as these are handled
automatically. One SELECT for super maintainers, one for maintainers. */ automatically. One SELECT for super maintainers, one for maintainers. */
$sQuery = "SELECT COUNT(DISTINCT maintainerId) as queued_maintainers FROM $sQuery = "(SELECT COUNT(DISTINCT maintainerId) as count FROM
appMaintainers, appFamily, appVersion WHERE appMaintainers, appFamily WHERE
appMaintainers.queued = '?' appMaintainers.queued = '?'
AND AND
appFamily.appId = appVersion.appId appMaintainers.superMaintainer = '1'
AND AND
( appFamily.appId = appMaintainers.appId
( AND
appFamily.appId = appMaintainers.appId appFamily.queued = 'false') UNION
AND (SELECT COUNT(DISTINCT maintainerId) as count FROM
appFamily.queued = 'false' appMaintainers, appVersion WHERE
AND appMaintainers.queued = '?'
appMaintainers.versionId = '' AND
) appMaintainers.versionId = appVersion.versionId
OR AND
( appMaintainers.superMaintainer = '0'
appVersion.versionId = appMaintainers.versionId AND
AND appVersion.queued = 'false')";
appVersion.queued = 'false'
)
)";
if(!($hResult = query_parameters($sQuery, $bQueued ? "true" : "false"))) if(!($hResult = query_parameters($sQuery, $bQueued ? "true" : "false",
$bQueued ? "true" : "false")))
return 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 */ /* see how many maintainer entries we have in the database */
@@ -782,6 +811,13 @@ class maintainer
return TRUE; return TRUE;
} }
function objectGetItemsPerPage($bQueued = false)
{
$aItemsPerPage = array(25, 50, 100, 200);
$iDefaultPerPage = 25;
return array($aItemsPerPage, $iDefaultPerPage);
}
function update() function update()
{ {
/* STUB: No updating possible at the moment */ /* STUB: No updating possible at the moment */