Patch to limit testing results in AppDB
Chris Morgan
chmorgan at gmail.com
Sat Jan 28 10:13:08 CST 2006
Looks good. I'll test and check this in this evening. Thanks for the patch.
Chris
On 1/28/06, Jason Weisberger <jbdubbs at gmail.com> wrote:
> You'd be right :)
>
> I didn't think about not having to check if the results were less than 5,
> because if they are in fact less, it doesn't matter if we stick the limit on
> it. So here's the edited patch:
>
> Index: appdb/include/testResults.php
> ===================================================================
> RCS file: /home/wine/appdb/include/testResults.php,v
> retrieving revision 1.8
> diff -u -r1.8 testResults.php
> --- appdb/include/testResults.php 23 Jan 2006 02:10:32
> -0000 1.8
> +++ appdb/include/testResults.php 27 Jan 2006 03:05:51
> -0000
> @@ -324,6 +324,7 @@
>
> function ShowTestResult($iCurrentTest,$iVersionId)
> {
> +
> $hResult = query_appdb("SELECT *
> FROM testResults
> WHERE testingId =
> '".$iCurrentTest."';");
> @@ -349,11 +350,21 @@
> // Show the Test results for a application version
> function ShowVersionsTestingTable($iVersionId,
> $iCurrentTest, $link)
> {
> - $hResult = query_appdb("SELECT *
> - FROM testResults
> - WHERE versionId =
> '".$iVersionId."'
> - ORDER BY testedDate
> DESC;");
> - if(!$hResult || mysql_num_rows($hResult) == 0)
> + $showAll = $_REQUEST['showAll'];
> +
> + $sQuery = "SELECT *
> + FROM testResults
> + WHERE versionId = '".$iVersionId."'
> + ORDER BY testedDate DESC";
> +
> + if(!$showAll) {
> + $sQuery.=" LIMIT 0,5;";
> + }
> +
> + $hResult = query_appdb($sQuery);
> + $rowsUsed = mysql_num_rows($hResult);
> +
> + if(!$hResult || $rowsUsed == 0)
> return;
> echo '<p><span class="title">Testing Results</span><br />',"\n";
> echo '<table width="100%" border="1" class="historyTable">',"\n";
> @@ -379,7 +390,9 @@
> if ($oTest->iTestingId == $iCurrentTest)
> echo ' <td align="center"
> class="color2"><b>Current</b></td>',"\n";
> else
> - echo ' <td align="center" class="color2">[<a
> href="'.$link.$oTest->iTestingId.'">Show</a>]</td>',"\n";
> + echo ' <td align="center" class="color2">[<a
> href="'.$link.$oTest->iTestingId;
> + if(is_string($showAll)) echo
> '&showAll='.$showAll.'">Show</a>]</td>',"\n";
> + else echo '">Show</a>]</td>',"\n";
> echo ' <td>',"\n";
> echo '<a
> href="'.BASE.'distributionView.php?iDistributionId='.$oTest->iDistributionId.'">',"\n";
> echo $oDistribution->sName.'</a>',"\n";
> @@ -393,6 +406,17 @@
> }
>
> echo '</table>',"\n";
> +
> + echo '<form method=get action="'.$PHP_SELF.'">';
> + echo '<input name="versionId" type=hidden value="',$iVersionId,'" />';
> + if($rowsUsed >= 5 AND !is_string($showAll)) {
> + echo '<input class="button" name="showAll" type=submit value="Show
> All Tests" />';
> + }
> + if(is_string($showAll)) {
> + echo '<input class="button" name="hideAll" type=submit value="Limit
> to 5 Tests" />';
> + unset($showAll);
> + }
> + echo '</form>';
>
>
> }
>
>
>
> On 1/27/06, Chris Morgan <cmorgan at alum.wpi.edu> wrote:
> > On Thursday 26 January 2006 9:14 pm, Jason Weisberger wrote:
> > > > if(showingAll or less than X items)
> > > > sql without a limit
> > > > else
> > >
> > > sql with a limit
> > >
> > >
> > > That's exactly the idea. Correct me if I'm wrong, but I didn't think I
> > > could tone it down any more than that. We'd need one query to get the
> > > number of results in the first place and to have the conditionals run on
> > > it, then we'd need to adjust $hResult to run the appropriate query for
> the
> > > rest of the function. That's only 2 of them for the whole function. We
> > > can't test for the conditionals without that first query and we can't
> run
> > > the appropriate one without the second. As usual correct me if I'm
> wrong.
> > > I'm sort of using this as a learning experience :) Perhaps if I'm too
> > > thick headed, feel free to show me what you mean in the patch itself.
> > >
> >
> > Sure.
> >
> > I'd do this:
> >
> > $sQuery = "SELECT *
> > FROM testResults
> > WHERE versionId = '".$iVersionId."'
> > ORDER BY testedDate DESC";
> >
> > /* if we aren't showing all entries we should append a limit to the sql */
> > if(!$showAll)
> > $sQuery.=" LIMIT 0,".$max_entries_limit;
> >
> > $hResult = query_appdb($sQuery);
> > if(!$hResult) return;
> >
> > Isn't this the same?
> >
> > Chris
> >
>
>
>
> --
> Jason Weisberger
> jbdubbs at gmail.com
>
More information about the wine-patches
mailing list