[AppDB] Use latest test for version rating
Rosanne DiMesio
dimesio at earthlink.net
Wed Jun 14 09:03:22 CDT 2017
Fixes bug 19377.
Signed-off-by: Rosanne DiMesio <dimesio at earthlink.net>
---
include/testData.php | 84 ++++++++--------------------------------------------
include/version.php | 8 ++---
2 files changed, 16 insertions(+), 76 deletions(-)
diff --git a/include/testData.php b/include/testData.php
index 61b23a0..bf5b727 100644
--- a/include/testData.php
+++ b/include/testData.php
@@ -185,6 +185,13 @@ class testData{
$sWhatChanged .= "Tested release was changed from ".
$oOldTest->sTestedRelease." to $this->sTestedRelease.\n";
}
+
+ if($this->iStaging != $oOldTest->iStaging)
+ {
+ $bUpdateRatingInfo = true;
+ $sWhatChanged .= "Staging checkbox was changed from ".
+ $oOldTest->iStaging." to $this->iStaging.\n";
+ }
if($this->iVersionId != $oOldTest->iVersionId)
{
@@ -729,79 +736,12 @@ class testData{
/* Gets rating info for the selected version: an array with the elements
0 - Rating
- 1 - Wine version
- The $sDate parameter can be used to calculate the rating at a given point in time */
- public static function getRatingInfoForVersionId($iVersionId, $sDate = 'NOW()')
+ 1 - Wine version (including staging info)*/
+ public static function getRatingInfoForVersionId($iVersionId)
{
- $sQuery = "SELECT testedRating,testedDate,testedRelease,staging,versions.id as versionId
- FROM testResults, ?.versions WHERE
- versions.value = testResults.testedRelease
- AND
- versions.product_id = '?'
- AND versionId = '?'
- AND
- state = '?'
- AND
- TO_DAYS(testedDate) > (TO_DAYS(?) - ?)
- ORDER BY versions.id DESC,testedDate DESC";
-
- $hResult = query_parameters($sQuery, BUGZILLA_DB, BUGZILLA_PRODUCT_ID, $iVersionId, 'accepted', $sDate, TESTDATA_AGED_THRESHOLD);
-
- $aEntries = array();
-
- if($hResult)
- {
- $iPrevRelease = 0;
- $iIndex = -1;
- for($i = 0; $oRow = query_fetch_object($hResult); $i++)
- {
- if($iPrevRelease != $oRow->versionId)
- {
- $iIndex++;
- $iPrevRelease = $oRow->versionId;
- }
-
- if(!$aEntries[$iIndex])
- {
- $aEntries[$iIndex] = array();
- $aEntries[$iIndex][0] = 0;
- $aEntries[$iIndex][1] = 0;
- $aEntries[$iIndex][2] = $oRow->testedRelease;
- }
-
- $aEntries[$iIndex][0] += testData::RatingToNumber($oRow->testedRating);
- $aEntries[$iIndex][1]++;
- }
- }
-
- $sRelease = '';
-
- if(sizeof($aEntries))
- {
- $fRating = 0.0;
-
- for($i = 0; $i < sizeof($aEntries); $i++)
- {
- /* Discard the rating if it's the only one for that Wine version
- and its score is lower than previous averages */
- if(($aEntries[$i][1] < 2) && sizeof($aEntries) > ($i+1) && ($aEntries[$i][0] < ($aEntries[$i+1][0] / $aEntries[$i+1][1])))
- continue;
-
- $fRating = $aEntries[$i][0] / $aEntries[$i][1];
- $sRelease = $aEntries[$i][2];
- break;
- }
-
- $sRating = testData::NumberToRating(round($fRating, 0));
- }
-
- if(!$sRelease)
- {
- $iNewestId = testData::getNewestTestIdFromVersionId($iVersionId);
- $oTestData = new testData($iNewestId);
- return array($oTestData->sTestedRating, $oTestData->sTestedRelease);
- }
- return array($sRating,$sRelease);
+ $iNewestId = testData::getNewestTestIdFromVersionId($iVersionId);
+ $oTestData = new testData($iNewestId);
+ return array($oTestData->sTestedRating, ($oTestData->sTestedRelease) . ($oTestData->iStaging != 0 ? '-staging':''));
}
/* retrieve the latest test result for a given version id */
diff --git a/include/version.php b/include/version.php
index 2c09be7..f75b711 100644
--- a/include/version.php
+++ b/include/version.php
@@ -1021,11 +1021,11 @@ class version {
<td>{$shVoteText}</td>
</tr>
<tr>
- <td><b>Rating:</b></td>
+ <td><b>Latest Rating:</b></td>
<td>{$this->sTestedRating}</td>
</tr>
<tr>
- <td><b>Wine Version:</b></td>
+ <td><b>Latest Wine Version Tested:</b></td>
<td>{$this->sTestedRelease}</td>
</tr>
</tbody>
@@ -1230,11 +1230,11 @@ EOT;
$oTableRow->AddTextCell("Description");
- $oTableCell = new TableCell("Rating");
+ $oTableCell = new TableCell("Latest Rating");
$oTableCell->SetWidth("80");
$oTableRow->AddCell($oTableCell);
- $oTableCell = new TableCell("Wine version");
+ $oTableCell = new TableCell("Latest Wine version tested");
$oTableCell->SetWidth("80");
$oTableRow->AddCell($oTableCell);
--
2.12.3
More information about the wine-patches
mailing list