Keep track of the appIds we've already output to the top X list. If we need

to fill the list in with applications that haven't received any votes make
sure we exclude the applications we've already output.
This commit is contained in:
Chris Morgan
2005-06-25 03:44:39 +00:00
committed by WineHQ
parent adf0dc83ab
commit 3342c55772

View File

@@ -256,6 +256,10 @@ function lookupVendorName($vendorId)
/* Output the rows for the Top-X tables on the main page */ /* Output the rows for the Top-X tables on the main page */
function outputTopXRowAppsFromRating($rating, $num_apps) function outputTopXRowAppsFromRating($rating, $num_apps)
{ {
/* list of appIds we've already output, so we don't output */
/* them again when filling in any empty spots in the list */
$appIdArray = array();
$sQuery = "SELECT appVotes.appId AS appId, COUNT( appVotes.appId ) AS c $sQuery = "SELECT appVotes.appId AS appId, COUNT( appVotes.appId ) AS c
FROM appVotes, appVersion FROM appVotes, appVersion
WHERE appVersion.maintainer_rating = '$rating' WHERE appVersion.maintainer_rating = '$rating'
@@ -267,6 +271,8 @@ function outputTopXRowAppsFromRating($rating, $num_apps)
$num_apps-=mysql_num_rows($hResult); /* take away the rows we are outputting here */ $num_apps-=mysql_num_rows($hResult); /* take away the rows we are outputting here */
while($oRow = mysql_fetch_object($hResult)) while($oRow = mysql_fetch_object($hResult))
{ {
array_push($appIdArray, $oRow->appId); /* keep track of the apps we've already output */
$oApp = new Application($oRow->appId); $oApp = new Application($oRow->appId);
// image // image
$img = get_screenshot_img($oRow->appId); $img = get_screenshot_img($oRow->appId);
@@ -284,8 +290,15 @@ function outputTopXRowAppsFromRating($rating, $num_apps)
WHERE appVersion.maintainer_rating = '$rating' WHERE appVersion.maintainer_rating = '$rating'
AND appVersion.versionId = appData.versionId AND appVersion.versionId = appData.versionId
AND appData.type = 'image' AND appData.type = 'image'
AND appData.queued = 'false' AND appData.queued = 'false'";
LIMIT $num_apps";
/* make sure we exclude any apps we've already output */
foreach($appIdArray as $key=>$value)
$sQuery.="AND appVersion.appId != '".$value."' ";
$sQuery.=" LIMIT $num_apps";
/* get the list that will fill the empty spots */
$hResult = query_appdb($sQuery); $hResult = query_appdb($sQuery);
while($oRow = mysql_fetch_object($hResult)) while($oRow = mysql_fetch_object($hResult))
{ {