You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@vcl.apache.org by jf...@apache.org on 2012/03/15 15:19:26 UTC

svn commit: r1300995 - /incubator/vcl/trunk/web/.ht-inc/help.php

Author: jfthomps
Date: Thu Mar 15 14:19:26 2012
New Revision: 1300995

URL: http://svn.apache.org/viewvc?rev=1300995&view=rev
Log:
modified submitHelpForm - improved how user reservation history is generated

Modified:
    incubator/vcl/trunk/web/.ht-inc/help.php

Modified: incubator/vcl/trunk/web/.ht-inc/help.php
URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/web/.ht-inc/help.php?rev=1300995&r1=1300994&r2=1300995&view=diff
==============================================================================
--- incubator/vcl/trunk/web/.ht-inc/help.php (original)
+++ incubator/vcl/trunk/web/.ht-inc/help.php Thu Mar 15 14:19:26 2012
@@ -152,19 +152,27 @@ function submitHelpForm() {
 	}
 
 	$computers = getComputers();
-	$requests = getUserRequests("all");
-	$query = "SELECT l.start AS start, "
+	$requests = array();
+	$query = "SELECT l.id, "
+	       .        "l.start, "
 	       .        "l.finalend AS end, "
-	       .        "l.computerid AS computerid, "
+	       .        "s.computerid, "
 	       .        "i.prettyname AS prettyimage "
 	       . "FROM log l, "
-	       .      "image i "
-	       . "WHERE l.userid = " . $user["id"] . " AND "
+	       .      "image i, "
+	       .      "sublog s "
+	       . "WHERE l.userid = {$user["id"]} AND "
 	       .        "i.id = l.imageid AND "
-	       .        "(unix_timestamp(NOW()) - unix_timestamp(l.finalend)) < 14400";
+	       .        "s.logid = l.id AND "
+	       .        "l.finalend < DATE_ADD(NOW(), INTERVAL 1 DAY) "
+	       . "ORDER BY l.finalend DESC "
+	       . "LIMIT 5";
 	$qh = doQuery($query, 290);
 	while($row = mysql_fetch_assoc($qh)) {
-		array_push($requests, $row);
+		# only include 1 computer from cluster reservations
+		if(array_key_exists($row['id'], $requests))
+			continue;
+		$requests[$row['id']] =  $row;
 	}
 
 	$from = $user["email"];
@@ -175,21 +183,16 @@ function submitHelpForm() {
 	         . "Name: " . $testname . "\n"
 	         . "Email: " . $email . "\n"
 	         . "Problem description:\n\n$text\n\n";
-	$end = time();
-	$start = $end - 14400;
 	$recentrequests = "";
 	foreach($requests as $request) {
-		if(datetimeToUnix($request["end"]) > $start ||
-		   datetimeToUnix($request["start"] < $end)) {
-			$thisstart = str_replace('&nbsp;', ' ', 
-			      prettyDatetime($request["start"]));
-			$thisend = str_replace('&nbsp;', ' ', 
-			      prettyDatetime($request["end"]));
-			$recentrequests .= "Image: " . $request["prettyimage"] . "\n"
-			   . "Computer: " . $computers[$request["computerid"]]["hostname"] . "\n"
-			   . "Start: $thisstart\n"
-			   . "End: $thisend\n\n";
-		}
+		$thisstart = str_replace('&nbsp;', ' ', 
+				prettyDatetime($request["start"]));
+		$thisend = str_replace('&nbsp;', ' ', 
+				prettyDatetime($request["end"]));
+		$recentrequests .= "Image: {$request["prettyimage"]}\n"
+		                .  "Computer: {$computers[$request["computerid"]]["hostname"]}\n"
+		                .  "Start: $thisstart\n"
+		                .  "End: $thisend\n\n";
 	}
 	if(! empty($recentrequests)) {
 		$message .= "-----------------------------------------------\n";
@@ -199,7 +202,6 @@ function submitHelpForm() {
 		$message .= "User has no recent reservations\n";
 	}
 
-
 	$indrupal = getContinuationVar('indrupal', 0);
 	if(! $indrupal)
 		print "<H2>VCL Help</H2>\n";