testData: Rename 'queued' to 'state'

This commit is contained in:
Alexander Nicolaysen Sørnes
2007-12-12 20:17:27 +01:00
committed by Chris Morgan
parent 956e5391de
commit 06f693859f
5 changed files with 69 additions and 50 deletions

View File

@@ -59,7 +59,7 @@ class distribution {
{ {
$sQuery = "SELECT testingId $sQuery = "SELECT testingId
FROM testResults, appFamily, appVersion FROM testResults, appFamily, appVersion
WHERE testResults.queued = 'false' AND WHERE testResults.state = 'accepted' AND
testResults.versionId = appVersion.versionId AND testResults.versionId = appVersion.versionId AND
appFamily.appId = appVersion.appId AND appFamily.appId = appVersion.appId AND
appFamily.queued = 'false' AND appFamily.queued = 'false' AND
@@ -251,8 +251,8 @@ class distribution {
return false; return false;
} }
if(query_parameters("UPDATE testResults SET queued = '?' WHERE testingId = '?'", if(query_parameters("UPDATE testResults SET state = '?' WHERE testingId = '?'",
"true", $this->iTestingId)) 'queued', $this->iTestingId))
{ {
if(query_parameters("UPDATE distribution SET state = '?' WHERE distributionId = '?'", if(query_parameters("UPDATE distribution SET state = '?' WHERE distributionId = '?'",
'queued', $this->iDistributionId)) 'queued', $this->iDistributionId))

View File

@@ -96,8 +96,8 @@ class queuedEntries
// queued testdata // queued testdata
// retrieve queued testdata for this version // retrieve queued testdata for this version
$sQuery = "select * from testResults where versionId = '?' and queued = '?'"; $sQuery = "select * from testResults where versionId = '?' and state = '?'";
$hResult = query_parameters($sQuery, $iVersionId, "true"); $hResult = query_parameters($sQuery, $iVersionId, 'queued');
// go through the test results looking for the oldest queued data // go through the test results looking for the oldest queued data
while($oTestingRow = query_fetch_object($hResult)) while($oTestingRow = query_fetch_object($hResult))

View File

@@ -1391,6 +1391,20 @@ class ObjectManager
return $sQueueString; return $sQueueString;
} }
public function getStateString($bQueued, $bRejected)
{
if($bQueued)
{
if($bRejected)
$sStateString = 'rejected';
else
$sStateString = 'queued';
} else
$sStateString = 'accepted';
return $sStateString;
}
private function displayErrors($sErrors) private function displayErrors($sErrors)
{ {
if($sErrors) if($sErrors)

View File

@@ -21,7 +21,7 @@ class testData{
var $sComments; var $sComments;
var $sSubmitTime; var $sSubmitTime;
var $iSubmitterId; var $iSubmitterId;
var $sQueued; private $sState;
// constructor, fetches the data. // constructor, fetches the data.
function testData($iTestingId = null, $oRow = null) function testData($iTestingId = null, $oRow = null)
@@ -56,7 +56,7 @@ class testData{
$this->sComments = $oRow->comments; $this->sComments = $oRow->comments;
$this->sSubmitTime = $oRow->submitTime; $this->sSubmitTime = $oRow->submitTime;
$this->iSubmitterId = $oRow->submitterId; $this->iSubmitterId = $oRow->submitterId;
$this->sQueued = $oRow->queued; $this->sState = $oRow->state;
} }
} }
@@ -65,14 +65,14 @@ class testData{
{ {
$oVersion = new version($this->iVersionId); $oVersion = new version($this->iVersionId);
if($oVersion->sQueued != "false") if($oVersion->sQueued != "false")
$this->sQueued = "pending"; $this->sState = 'pending';
else else
$this->sQueued = $this->mustBeQueued() ? "true" : "false"; $this->sState = $this->mustBeQueued() ? 'queued' : 'accepted';
$hResult = query_parameters("INSERT INTO testResults (versionId, whatWorks, whatDoesnt,". $hResult = query_parameters("INSERT INTO testResults (versionId, whatWorks, whatDoesnt,".
"whatNotTested, testedDate, distributionId, testedRelease,". "whatNotTested, testedDate, distributionId, testedRelease,".
"installs, runs, testedRating, comments,". "installs, runs, testedRating, comments,".
"submitTime, submitterId, queued)". "submitTime, submitterId, state)".
"VALUES('?', '?', '?', '?', '?', '?', '?',". "VALUES('?', '?', '?', '?', '?', '?', '?',".
"'?', '?', '?', '?',". "'?', '?', '?', '?',".
"?, '?', '?')", "?, '?', '?')",
@@ -85,7 +85,7 @@ class testData{
$this->sTestedRating, $this->sComments, $this->sTestedRating, $this->sComments,
"NOW()", "NOW()",
$_SESSION['current']->iUserId, $_SESSION['current']->iUserId,
$this->sQueued); $this->sState);
if($hResult) if($hResult)
{ {
@@ -108,7 +108,7 @@ class testData{
$oVersion = new Version($this->iVersionId); $oVersion = new Version($this->iVersionId);
if(!$_SESSION['current']->hasPriv("admin") && if(!$_SESSION['current']->hasPriv("admin") &&
!$_SESSION['current']->hasAppVersionModifyPermission($oVersion) && !$_SESSION['current']->hasAppVersionModifyPermission($oVersion) &&
!(($_SESSION['current']->iUserId == $this->iSubmitterId) && !($this->sQueued == 'false'))) !(($_SESSION['current']->iUserId == $this->iSubmitterId) && $this->sState != 'accepted'))
{ {
return; return;
} }
@@ -221,7 +221,7 @@ class testData{
$oVersion = new Version($this->iVersionId); $oVersion = new Version($this->iVersionId);
if(!$_SESSION['current']->hasPriv("admin") && if(!$_SESSION['current']->hasPriv("admin") &&
!$_SESSION['current']->hasAppVersionModifyPermission($oVersion) && !$_SESSION['current']->hasAppVersionModifyPermission($oVersion) &&
!(($_SESSION['current']->iUserId == $this->iSubmitterId) && !($this->sQueued == 'false'))) !(($_SESSION['current']->iUserId == $this->iSubmitterId) && $this->sState != 'accepted'))
{ {
return false; return false;
} }
@@ -252,13 +252,13 @@ class testData{
} }
// If we are not in the queue, we can't move the test data out of the queue. // If we are not in the queue, we can't move the test data out of the queue.
if($this->sQueued == 'false') if($this->sState == 'accepted')
return false; return false;
if(query_parameters("UPDATE testResults SET queued = '?' WHERE testingId = '?'", if(query_parameters("UPDATE testResults SET state = '?' WHERE testingId = '?'",
"false", $this->iTestingId)) 'accepted', $this->iTestingId))
{ {
$this->sQueued = 'false'; $this->sState = 'accepted';
// we send an e-mail to interested people // we send an e-mail to interested people
$this->mailSubmitter("add"); $this->mailSubmitter("add");
$this->SendNotificationMail(); $this->SendNotificationMail();
@@ -281,13 +281,13 @@ class testData{
} }
// If we are not in the queue, we can't move the version out of the queue. // If we are not in the queue, we can't move the version out of the queue.
if(!$this->sQueued == 'true') if($this->sState != 'queued')
return false; return false;
if(query_parameters("UPDATE testResults SET queued = '?' WHERE testingId = '?'", if(query_parameters("UPDATE testResults SET state = '?' WHERE testingId = '?'",
"rejected", $this->iTestingId)) 'rejected', $this->iTestingId))
{ {
$this->sQueued = 'rejected'; $this->sState = 'rejected';
// we send an e-mail to interested people // we send an e-mail to interested people
$this->mailSubmitter("reject"); $this->mailSubmitter("reject");
$this->SendNotificationMail("reject"); $this->SendNotificationMail("reject");
@@ -305,10 +305,10 @@ class testData{
return; return;
} }
if(query_parameters("UPDATE testResults SET queued = '?' WHERE testingId = '?'", if(query_parameters("UPDATE testResults SET state = '?' WHERE testingId = '?'",
"true", $this->iTestingId)) 'queued', $this->iTestingId))
{ {
$this->sQueued = 'true'; $this->sState = 'queued';
// we send an e-mail to interested people // we send an e-mail to interested people
$this->SendNotificationMail(); $this->SendNotificationMail();
} }
@@ -418,7 +418,7 @@ class testData{
switch($sAction) switch($sAction)
{ {
case "add": case "add":
if($this->sQueued == "false") if($this->sState == 'accepted')
{ {
$sSubject = "Test Results added to version ".$oVersion->sName." of ".$oApp->sName." by ".$_SESSION['current']->sRealname; $sSubject = "Test Results added to version ".$oVersion->sName." of ".$oApp->sName." by ".$_SESSION['current']->sRealname;
$sMsg .= $sBacklink; $sMsg .= $sBacklink;
@@ -592,13 +592,13 @@ class testData{
FROM testResults FROM testResults
WHERE versionId = '?' WHERE versionId = '?'
AND AND
queued = '?' state = '?'
ORDER BY testedDate DESC"; ORDER BY testedDate DESC";
if(!$bShowAll) if(!$bShowAll)
$sQuery.=" LIMIT 0,".$iDisplayLimit; $sQuery.=" LIMIT 0,".$iDisplayLimit;
$hResult = query_parameters($sQuery, $this->iVersionId, "false"); $hResult = query_parameters($sQuery, $this->iVersionId, 'accepted');
if(!$hResult) if(!$hResult)
return; return;
@@ -648,15 +648,15 @@ class testData{
} }
/* retrieve the latest test result for a given version id */ /* retrieve the latest test result for a given version id */
function getNewestTestIdFromVersionId($iVersionId, $sQueued = "false") function getNewestTestIdFromVersionId($iVersionId, $sState = 'accepted')
{ {
$sQuery = "SELECT testingId FROM testResults WHERE $sQuery = "SELECT testingId FROM testResults WHERE
versionId = '?' versionId = '?'
AND AND
queued = '?' state = '?'
ORDER BY testedDate DESC limit 1"; ORDER BY testedDate DESC limit 1";
$hResult = query_parameters($sQuery, $iVersionId, $sQueued); $hResult = query_parameters($sQuery, $iVersionId, $sState);
if(!$hResult) if(!$hResult)
return 0; return 0;
@@ -705,7 +705,7 @@ class testData{
// Distribution // Distribution
$oDistribution = new distribution($this->iDistributionId); $oDistribution = new distribution($this->iDistributionId);
$sDistributionHelp = ""; $sDistributionHelp = "";
if(!$this->iDistributionId || $oDistribution->sQueued != "false") if(!$this->iDistributionId || $oDistribution->objectGetState() != 'accepted')
{ {
if(!$this->iDistributionId) if(!$this->iDistributionId)
{ {
@@ -876,7 +876,7 @@ class testData{
/* List test data submitted by a given user. Ignore test results for queued applications/versions */ /* List test data submitted by a given user. Ignore test results for queued applications/versions */
function listSubmittedBy($iUserId, $bQueued = true) function listSubmittedBy($iUserId, $bQueued = true)
{ {
$hResult = query_parameters("SELECT testResults.versionId, testResults.testedDate, testResults.testedRelease, testResults.testedRating, testResults.submitTime, appFamily.appName, appVersion.versionName from testResults, appFamily, appVersion WHERE testResults.versionId = appVersion.versionId AND appVersion.appId = appFamily.appId AND (appFamily.queued = '?' OR appVersion.queued = '?') AND testResults.submitterId = '?' AND testResults.queued = '?' ORDER BY testResults.testingId", "false", "false", $iUserId, $bQueued ? "true" : "false"); $hResult = query_parameters("SELECT testResults.versionId, testResults.testedDate, testResults.testedRelease, testResults.testedRating, testResults.submitTime, appFamily.appName, appVersion.versionName from testResults, appFamily, appVersion WHERE testResults.versionId = appVersion.versionId AND appVersion.appId = appFamily.appId AND (appFamily.queued = '?' OR appVersion.queued = '?') AND testResults.submitterId = '?' AND testResults.state = '?' ORDER BY testResults.testingId", "false", "false", $iUserId, $bQueued ? 'queued' : 'accepted');
if(!$hResult || !query_num_rows($hResult)) if(!$hResult || !query_num_rows($hResult))
return false; return false;
@@ -909,9 +909,9 @@ class testData{
FROM testResults FROM testResults
WHERE versionId = '?' WHERE versionId = '?'
AND AND
queued = '?';"; state = '?';";
$hResult = query_parameters($sQuery, $iVersionId, 'false'); $hResult = query_parameters($sQuery, $iVersionId, 'accepted');
$oRow = query_fetch_object($hResult); $oRow = query_fetch_object($hResult);
return $oRow->cnt; return $oRow->cnt;
@@ -920,7 +920,7 @@ class testData{
function objectGetEntriesCount($bQueued, $bRejected) function objectGetEntriesCount($bQueued, $bRejected)
{ {
$oTest = new testData(); $oTest = new testData();
$sQueued = objectManager::getQueueString($bQueued, $bRejected); $sState = objectManager::getStateString($bQueued, $bRejected);
if($bQueued && !$oTest->canEdit()) if($bQueued && !$oTest->canEdit())
{ {
if($bRejected) if($bRejected)
@@ -929,7 +929,7 @@ class testData{
testResults WHERE testResults WHERE
testResults.submitterId = '?' testResults.submitterId = '?'
AND AND
testResults.queued = '?'"; testResults.state = '?'";
} else } else
{ {
$sQuery = "SELECT COUNT(testingId) AS count FROM $sQuery = "SELECT COUNT(testingId) AS count FROM
@@ -954,16 +954,16 @@ class testData{
) )
) )
AND AND
testResults.queued = '?'"; testResults.state = '?'";
} }
$hResult = query_parameters($sQuery, $_SESSION['current']->iUserId, $hResult = query_parameters($sQuery, $_SESSION['current']->iUserId,
$sQueued); $sState);
} else } else
{ {
$sQuery = "SELECT COUNT(testingId) as count FROM testResults WHERE $sQuery = "SELECT COUNT(testingId) as count FROM testResults WHERE
testResults.queued = '?'"; testResults.state = '?'";
$hResult = query_parameters($sQuery, $sQueued); $hResult = query_parameters($sQuery, $sState);
} }
if(!$hResult) if(!$hResult)
@@ -978,7 +978,7 @@ class testData{
function objectGetEntries($bQueued, $bRejected, $iRows = 0, $iStart = 0, $sOrderBy = "testingId") function objectGetEntries($bQueued, $bRejected, $iRows = 0, $iStart = 0, $sOrderBy = "testingId")
{ {
$oTest = new testData(); $oTest = new testData();
$sQueued = objectManager::getQueueString($bQueued, $bRejected); $sState = objectManager::getStateString($bQueued, $bRejected);
$sLimit = ""; $sLimit = "";
@@ -1000,7 +1000,7 @@ class testData{
$sQuery = "SELECT testResults.* FROM testResults WHERE $sQuery = "SELECT testResults.* FROM testResults WHERE
testResults.submitterId = '?' testResults.submitterId = '?'
AND AND
testResults.queued = '?' ORDER BY ?$sLimit"; testResults.state = '?' ORDER BY ?$sLimit";
} else } else
{ {
$sQuery = "SELECT testResults.* FROM testResults, appVersion, $sQuery = "SELECT testResults.* FROM testResults, appVersion,
@@ -1025,25 +1025,25 @@ class testData{
AND AND
appMaintainers.queued = 'false' appMaintainers.queued = 'false'
AND AND
testResults.queued = '?' ORDER BY ?$sLimit"; testResults.state = '?' ORDER BY ?$sLimit";
} }
if($sLimit) if($sLimit)
{ {
$hResult = query_parameters($sQuery, $_SESSION['current']->iUserId, $hResult = query_parameters($sQuery, $_SESSION['current']->iUserId,
$sQueued, $sOrderBy, $iStart, $iRows); $sState, $sOrderBy, $iStart, $iRows);
} else } else
{ {
$hResult = query_parameters($sQuery, $_SESSION['current']->iUserId, $hResult = query_parameters($sQuery, $_SESSION['current']->iUserId,
$sQueued, $sOrderBy); $sState, $sOrderBy);
} }
} else } else
{ {
$sQuery = "SELECT testResults.* FROM testResults WHERE $sQuery = "SELECT testResults.* FROM testResults WHERE
testResults.queued = '?' ORDER by ?$sLimit"; testResults.state = '?' ORDER by ?$sLimit";
if($sLimit) if($sLimit)
$hResult = query_parameters($sQuery, $sQueued, $sOrderBy, $iStart, $iRows); $hResult = query_parameters($sQuery, $sState, $sOrderBy, $iStart, $iRows);
else else
$hResult = query_parameters($sQuery, $sQueued, $sOrderBy); $hResult = query_parameters($sQuery, $sState, $sOrderBy);
} }
if(!$hResult) if(!$hResult)
@@ -1091,6 +1091,11 @@ class testData{
return $oOMTableRow; return $oOMTableRow;
} }
public function objectGetState()
{
return $this->sState;
}
function canEdit() function canEdit()
{ {
if($_SESSION['current']->hasPriv("admin")) if($_SESSION['current']->hasPriv("admin"))
@@ -1098,7 +1103,7 @@ class testData{
else if($this->iVersionId) else if($this->iVersionId)
{ {
if($this->iSubmitterId == $_SESSION['current']->iUserId && if($this->iSubmitterId == $_SESSION['current']->iUserId &&
$this->sQueued == "rejected") $this->sState == 'rejected')
return TRUE; return TRUE;
$oVersion = new version($this->iVersionId); $oVersion = new version($this->iVersionId);

View File

@@ -20,6 +20,6 @@ create table testResults (
comments text, comments text,
submitTime datetime NOT NULL, submitTime datetime NOT NULL,
submitterId int(11) NOT NULL default '0', submitterId int(11) NOT NULL default '0',
queued enum('true','false','rejected','pending') NOT NULL default 'false', state enum('accepted','queued','rejected','pending') NOT NULL default 'accepted',
key(testingId) key(testingId)
); );