Alexander Nicolaysen Sørnes : testData: Allow users to only show entries for unmaintained versions

Alexander Nicolaysen Sørnes asornes at winehq.org
Thu Nov 12 17:18:40 CST 2009


Module: appdb
Branch: master
Commit: abb82efe505decb39f16f99af50b8bcd542f1c89
URL:    http://source.winehq.org/git/appdb.git/?a=commit;h=abb82efe505decb39f16f99af50b8bcd542f1c89

Author: Alexander Nicolaysen Sørnes <alexander at linux-xqqm.(none)>
Date:   Thu Nov 12 17:34:39 2009 +0100

testData: Allow users to only show entries for unmaintained versions

---

 include/testData.php       |   53 ++++++++++++++++++++++++++++++++++----------
 include/testData_queue.php |   13 +++++++---
 2 files changed, 50 insertions(+), 16 deletions(-)

diff --git a/include/testData.php b/include/testData.php
index 33661b1..19007d6 100644
--- a/include/testData.php
+++ b/include/testData.php
@@ -1171,8 +1171,26 @@ class testData{
         return $oRow->cnt;
     }
 
-    function objectGetEntriesCount($sState)
+    public function objectGetFilterInfo()
     {
+        $oFilter = new FilterInterface();
+        $oFilter->AddFilterInfo('onlyWithoutMaintainers', 'Only show test data for versions without maintainers', array(FILTER_OPTION_BOOL), FILTER_VALUES_OPTION_BOOL, array('false','true'));
+        return $oFilter;
+    }
+
+    function objectGetEntriesCount($sState, $oFilters = null)
+    {
+        $sExtraTables = '';
+        $aOptions = $oFilters ? $oFilters->getOptions() : array('onlyWithoutMaintainers' => 'false');
+        $sWhereFilter = '';
+
+        if($aOptions['onlyWithoutMaintainers'] == 'true')
+        {
+            $sExtraTables = ',appVersion';
+
+            $sWhereFilter .= " AND appVersion.hasMaintainer = 'false' AND appVersion.versionId = testResults.versionId";
+        }
+
         $oTest = new testData();
 
         if($sState != 'accepted' && !$oTest->canEdit())
@@ -1180,10 +1198,10 @@ class testData{
             if($sState == 'rejected')
             {
                 $sQuery = "SELECT COUNT(testingId) AS count FROM
-                        testResults WHERE
+                        testResults$sExtraTables WHERE
                         testResults.submitterId = '?'
                         AND
-                        testResults.state = '?'";
+                        testResults.state = '?'$sWhereFilter";
             } else
             {
                 $sQuery = "SELECT COUNT(testingId) AS count FROM
@@ -1208,15 +1226,15 @@ class testData{
                                 )
                             )
                             AND
-                            testResults.state = '?'";
+                            testResults.state = '?'$sWhereFilter";
             }
 
             $hResult = query_parameters($sQuery, $_SESSION['current']->iUserId,
                                         $sState);
         } else
         {
-            $sQuery = "SELECT COUNT(testingId) as count FROM testResults WHERE
-                    testResults.state = '?'";
+            $sQuery = "SELECT COUNT(testingId) as count FROM testResults$sExtraTables WHERE
+                    testResults.state = '?'$sWhereFilter";
             $hResult = query_parameters($sQuery, $sState);
         }
 
@@ -1234,8 +1252,19 @@ class testData{
         return 'testingId';
     }
 
-    function objectGetEntries($sState, $iRows = 0, $iStart = 0, $sOrderBy = "testingId", $bAscending = true)
+    function objectGetEntries($sState, $iRows = 0, $iStart = 0, $sOrderBy = "testingId", $bAscending = true, $oFilters = null)
     {
+        $sExtraTables = '';
+        $aOptions = $oFilters ? $oFilters->getOptions() : array('onlyWithoutMaintainers' => 'false');
+        $sWhereFilter = '';
+
+        if($aOptions['onlyWithoutMaintainers'] == 'true')
+        {
+            $sExtraTables = ',appVersion';
+
+            $sWhereFilter .= " AND appVersion.hasMaintainer = 'false' AND appVersion.versionId = testResults.versionId";
+        }
+
         $oTest = new testData();
 
         $sLimit = "";
@@ -1255,10 +1284,10 @@ class testData{
         {
             if($sState == 'rejected')
             {
-                $sQuery = "SELECT testResults.* FROM testResults WHERE
+                $sQuery = "SELECT testResults.* FROM testResults$sExtraTables WHERE
                         testResults.submitterId = '?'
                         AND
-                        testResults.state = '?' ORDER BY ?$sLimit";
+                        testResults.state = '?'$sWhereFilter ORDER BY ?$sLimit";
             } else
             {
                 $sQuery = "SELECT testResults.* FROM testResults, appVersion,
@@ -1283,7 +1312,7 @@ class testData{
                             AND
                             appMaintainers.state = 'accepted'
                             AND
-                            testResults.state = '?' ORDER BY ?$sLimit";
+                            testResults.state = '?'$sWhereFilter ORDER BY ?$sLimit";
             }
             if($sLimit)
             {
@@ -1296,8 +1325,8 @@ class testData{
             }
         } else
         {
-            $sQuery = "SELECT testResults.* FROM testResults WHERE
-                    testResults.state = '?' ORDER by ?$sLimit";
+            $sQuery = "SELECT testResults.* FROM testResults$sExtraTables WHERE
+                    testResults.state = '?'$sWhereFilter ORDER by ?$sLimit";
             if($sLimit)
                 $hResult = query_parameters($sQuery, $sState, $sOrderBy, $iStart, $iRows);
             else
diff --git a/include/testData_queue.php b/include/testData_queue.php
index fcc5992..0877535 100644
--- a/include/testData_queue.php
+++ b/include/testData_queue.php
@@ -147,14 +147,19 @@ class testData_queue
         return testData::objectGetDefaultSort();
     }
 
-    function objectGetEntries($sState, $iRows = 0, $iStart = 0, $sOrderBy = "testingId", $bAscending = true)
+    public function objectGetFilterInfo()
     {
-        return $this->oTestData->objectGetEntries($sState, $iRows, $iStart, $sOrderBy, $bAscending);
+        return testData::objectGetFilterInfo();
     }
 
-    function objectGetEntriesCount($sState)
+    function objectGetEntries($sState, $iRows = 0, $iStart = 0, $sOrderBy = "testingId", $bAscending = true, $oFilters = null)
     {
-        return testData::objectGetEntriesCount($sState);
+        return $this->oTestData->objectGetEntries($sState, $iRows, $iStart, $sOrderBy, $bAscending, $oFilters);
+    }
+
+    function objectGetEntriesCount($sState, $oFilters = null)
+    {
+        return testData::objectGetEntriesCount($sState, $oFilters);
     }
 
     function objectGetHeader()




More information about the wine-cvs mailing list