maintainer: Simplify SQL code

This commit is contained in:
Alexander Nicolaysen Sørnes
2007-11-06 15:29:58 +01:00
committed by Chris Morgan
parent 734a4f8a1f
commit b3e71b0a81

View File

@@ -410,24 +410,8 @@ class maintainer
/* 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 * FROM appMaintainers WHERE
appMaintainers, appFamily WHERE appMaintainers.queued = '?'$sLimit";
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";
if($bQueued) if($bQueued)
{ {
@@ -435,13 +419,10 @@ class maintainer
{ {
if($sLimit) if($sLimit)
{ {
return query_parameters($sQuery, $bQueued ? "true" : "false", return query_parameters($sQuery, $bQueued ? "true" : "false", $iStart, $iRows);
$bQueued ? "true" : "false",
$iStart, $iRows);
} else } else
{ {
return query_parameters($sQuery, $bQueued ? "true" : "false", return query_parameters($sQuery, $bQueued ? "true" : "false");
$bQueued ? "true" : "false");
} }
} else } else
{ {
@@ -451,12 +432,10 @@ class maintainer
{ {
if($sLimit) if($sLimit)
{ {
return query_parameters($sQuery, $bQueued ? "true" : "false", return query_parameters($sQuery, $bQueued ? "true" : "false", $iStart, $iRows);
$bQueued ? "true" : "false", $iStart, $iRows);
} else } else
{ {
return query_parameters($sQuery, $bQueued ? "true" : "false", return query_parameters($sQuery, $bQueued ? "true" : "false");
$bQueued ? "true" : "false");
} }
} }
} }
@@ -512,31 +491,16 @@ 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 count FROM $sQuery = "SELECT COUNT(maintainerId) as count FROM appMaintainers WHERE
appMaintainers, appFamily WHERE appMaintainers.queued = '?'";
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; return FALSE;
for($iCount = 0; $oRow = query_fetch_object($hResult);) if($oRow = query_fetch_object($hResult))
$iCount += $oRow->count; $iCount = $oRow->count;
else
$iCount = 0;
return $iCount; return $iCount;
} }