Speedup maintainer::objectGetEntries and maintainer::objectGetEntriesCount. Use UNION for sql
statements and multipage controls
This commit is contained in:
committed by
WineHQ
parent
93dc3e0396
commit
f37fa6e42f
@@ -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'
|
||||
appFamily.queued = 'false') UNION
|
||||
(SELECT DISTINCT appMaintainers.* FROM
|
||||
appMaintainers, appVersion WHERE
|
||||
appMaintainers.queued = '?'
|
||||
AND
|
||||
appMaintainers.versionId = ''
|
||||
)
|
||||
OR
|
||||
(
|
||||
appVersion.versionId = appMaintainers.versionId
|
||||
appMaintainers.versionId = appVersion.versionId
|
||||
AND
|
||||
appVersion.queued = 'false'
|
||||
)
|
||||
)";
|
||||
appMaintainers.superMaintainer = '0'
|
||||
AND
|
||||
appVersion.queued = 'false')$sLimit";
|
||||
|
||||
if($bQueued)
|
||||
{
|
||||
if($_SESSION['current']->hasPriv("admin"))
|
||||
return query_parameters($sQuery, $bQueued ? "true" : "false");
|
||||
else
|
||||
return NULL;
|
||||
{
|
||||
if($sLimit)
|
||||
{
|
||||
return query_parameters($sQuery, $bQueued ? "true" : "false",
|
||||
$bQueued ? "true" : "false",
|
||||
$iStart, $iRows);
|
||||
} else
|
||||
{
|
||||
return query_parameters($sQuery, $bQueued ? "true" : "false");
|
||||
return query_parameters($sQuery, $bQueued ? "true" : "false",
|
||||
$bQueued ? "true" : "false");
|
||||
}
|
||||
} else
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
} 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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
$sQuery = "(SELECT COUNT(DISTINCT maintainerId) as count FROM
|
||||
appMaintainers, appFamily WHERE
|
||||
appMaintainers.queued = '?'
|
||||
AND
|
||||
appFamily.appId = appVersion.appId
|
||||
appMaintainers.superMaintainer = '1'
|
||||
AND
|
||||
(
|
||||
(
|
||||
appFamily.appId = appMaintainers.appId
|
||||
AND
|
||||
appFamily.queued = 'false'
|
||||
appFamily.queued = 'false') UNION
|
||||
(SELECT COUNT(DISTINCT maintainerId) as count FROM
|
||||
appMaintainers, appVersion WHERE
|
||||
appMaintainers.queued = '?'
|
||||
AND
|
||||
appMaintainers.versionId = ''
|
||||
)
|
||||
OR
|
||||
(
|
||||
appVersion.versionId = appMaintainers.versionId
|
||||
appMaintainers.versionId = appVersion.versionId
|
||||
AND
|
||||
appVersion.queued = 'false'
|
||||
)
|
||||
)";
|
||||
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 */
|
||||
|
||||
Reference in New Issue
Block a user