minor nitpicking and some patches
Edwin Groothuis
edwin at mavetju.org
Sat Dec 24 22:41:01 EST 2005
While trying to add some nifty features to my tinderbox (no, still
not managed to get it):
- The use of the function get_var() which returns either from $_POST
or from $_GET. You might want to check out $_REQUEST for that.
- I've attached a patch to display the unknown / leftover / fails
in the initial screen of www-exp.
Build Name Build Description U / F / L Build Packages
4.11-FreeBSD 4.11 with FreeBSD ports tree 7 / 2 / 25 Package Directory
5.4-FreeBSD 5.4 with FreeBSD ports tree - / - / 19 Package Directory
6.0-FreeBSD 6.0 with FreeBSD ports tree 10 / - / - Package Directory
The U/F/L has a textbox over it so it explains what U/F/L means.
See patch-unknown.txt
- I've attached a patch which sorts the output of action_list_ports
based on the users preferences (default port directory). What I
was after was a way to sort the column between the Version and
the Reason so that I could get a quick overview of builds which
had problems (and yes I consider leftover files a problem)
By lack of a better place to store homemade functions, I have
stored http_query() in www-exp/core/TinderboxDS.php.
- Line 59 of www-exp/templates/default/list_buildports.tpl does
have a statement which is outside a <td> tag.
- I've attached a patch which tells how long the current port is
already in the build.
Build Port Duration
6.0-FreeBSD libgnomeui-2.12.0_1 00:03:27
It requires a change in the database (add build_last_updated,
which is a time stamp, to builds), but I didn't know how to add
that one.
Here also goes, I've stored time_difference_from_now() in
www-exp/core/TinderboxDS.php.
Well, happy season greetings and a good MMVI.
Edwin
--
Edwin Groothuis | Personal website: http://www.mavetju.org
edwin at mavetju.org | Weblog: http://weblog.barnet.com.au/edwin/
-------------- next part --------------
diff -ru /root/tinderbox-2.2.0/www-exp/core/TinderboxDS.php www-exp/core/TinderboxDS.php
--- /root/tinderbox-2.2.0/www-exp/core/TinderboxDS.php Sat Dec 10 04:59:21 2005
+++ www-exp/core/TinderboxDS.php Sun Dec 25 10:06:24 2005
@@ -460,6 +460,12 @@
return $ports;
}
+ function getBuildStats2($build_id) {
+ $query = 'SELECT Last_Status,COUNT(*) AS c FROM build_ports WHERE Build_Id = ? GROUP BY Last_Status';
+ $rc = $this->_doQueryHashRef($query, $results, $build_id);
+ if (!$rc) return null;
+ return $results;
+ }
function getBuildStats($build_id) {
$query = 'SELECT COUNT(*) AS fails FROM build_ports WHERE Last_Status = \'FAIL\' AND Build_Id = ?';
diff -ru /root/tinderbox-2.2.0/www-exp/module/moduleBuilds.php www-exp/module/moduleBuilds.php
--- /root/tinderbox-2.2.0/www-exp/module/moduleBuilds.php Sat Dec 10 04:59:21 2005
+++ www-exp/module/moduleBuilds.php Sun Dec 25 10:22:31 2005
@@ -62,12 +62,23 @@
$i = 0;
foreach( $builds as $build ) {
- $stats = $this->TinderboxDS->getBuildStats( $build->getId() );
$status = $build->getBuildStatus();
$description = $build->getDescription();
$name = $build->getName();
- $failures = $stats['fails']?$stats['fails']:0;
+ $stats = $this->TinderboxDS->getBuildStats2( $build->getId() );
+ $results=array(
+ "UNKNOWN" => 0,
+ "FAIL" => 0,
+ "LEFTOVERS" => 0,
+ "SUCCESS" => 0,
+ );
+ foreach ($stats as $stat) {
+ $results[$stat["last_status"]]=$stat["c"];
+ }
+ foreach ($results as $k=>$v) {
+ if ($v==0) $results[$k]="-";
+ }
switch( $status ) {
case 'PORTBUILD':
@@ -89,7 +100,7 @@
} else {
$data[$i]['packagedir'] = false;
}
- $data[$i]['failures'] = $failures;
+ $data[$i]['results'] = $results;
$i++;
}
diff -ru /root/tinderbox-2.2.0/www-exp/templates/default/list_builds.tpl www-exp/templates/default/list_builds.tpl
--- /root/tinderbox-2.2.0/www-exp/templates/default/list_builds.tpl Sat Dec 10 04:59:21 2005
+++ www-exp/templates/default/list_builds.tpl Sun Dec 25 10:24:37 2005
@@ -13,7 +13,11 @@
<th style="width: 20px"> </th>
<th>Build Name</th>
<th>Build Description</th>
- <th>Failures</th>
+ <th>
+ <span title="unknown / fail / leftovers">
+ U / F / L
+ </span>
+ </th>
<th>Build Packages</th>
</tr>
@@ -22,7 +26,15 @@
<td class="<?=$row['status_field_class']?>"> </td>
<td><a href="index.php?action=list_buildports&build=<?=$row['name']?>"><?=$row['name']?></a></td>
<td><?=$row['description']?></td>
- <td align="center"><?=$row['failures']?></td>
+ <td align="center">
+ <span title="unknown / fail / leftovers">
+ <?=$row['results']['UNKNOWN']?>
+ /
+ <?=$row['results']['FAIL']?>
+ /
+ <?=$row['results']['LEFTOVERS']?>
+ </span>
+ </td>
<?if($row['packagedir']){?>
<td><a href="<?=$row['packagedir']?>">Package Directory</a></td>
<?}else{?>
-------------- next part --------------
diff -ru www-exp-barnet/core/TinderboxDS.php www-exp/core/TinderboxDS.php
--- www-exp-barnet/core/TinderboxDS.php Sun Dec 25 10:30:10 2005
+++ www-exp/core/TinderboxDS.php Sun Dec 25 13:23:34 2005
@@ -365,7 +365,11 @@
return true;
}
- function getPortsForBuild($build) {
+ function getPortsForBuild($build,$sortby='port_directory') {
+ $sortbytable="bp.";
+ if ($sortby=="") $sortby="port_directory";
+ if ($sortby=="port_directory") $sortbytable="p.";
+ if ($sortby=="port_maintainer") $sortbytable="p.";
$query = "SELECT p.*,
bp.Last_Built,
bp.Last_Status,
@@ -380,7 +384,7 @@
build_ports bp
WHERE p.Port_Id = bp.Port_Id
AND bp.Build_Id=?
- ORDER BY p.Port_Directory";
+ ORDER BY $sortbytable$sortby";
$rc = $this->_doQueryHashRef($query, $results, $build->getId());
@@ -835,5 +839,15 @@
return eregi_replace("@FreeBSD.org", "", $input);
}
+ }
+
+ function http_query($url,$qs,$k,$v) {
+ $qs[$k]=$v;
+ $s="";
+ foreach ($qs as $k=>$v) {
+ if ($s) $s.="&";
+ $s.="$k=$v";
+ }
+ return "$url?$s";
}
?>
diff -ru www-exp-barnet/index.php www-exp/index.php
--- www-exp-barnet/index.php Sun Dec 25 10:30:10 2005
+++ www-exp/index.php Sun Dec 25 10:40:11 2005
@@ -79,7 +79,8 @@
$display = $moduleBuildPorts->display_latest_buildports( $build );
break;
case 'list_buildports': $build = get_var( 'build' );
- $display = $moduleBuildPorts->display_list_buildports( $build );
+ $sort = get_var( 'sort' );
+ $display = $moduleBuildPorts->display_list_buildports( $build, $sort );
break;
case 'list_tinderd_queue': $host_id = get_var( 'filter_host_id' );
$build_id = get_var( 'filter_build_id' );
diff -ru www-exp-barnet/module/moduleBuildPorts.php www-exp/module/moduleBuildPorts.php
--- www-exp-barnet/module/moduleBuildPorts.php Sun Dec 25 10:30:10 2005
+++ www-exp/module/moduleBuildPorts.php Sun Dec 25 13:21:03 2005
@@ -37,10 +37,10 @@
$this->modulePorts = new modulePorts();
}
- function display_list_buildports( $build_name ) {
+ function display_list_buildports( $build_name, $sort ) {
$build = $this->TinderboxDS->getBuildByName( $build_name );
- $ports = $this->TinderboxDS->getPortsForBuild( $build );
+ $ports = $this->TinderboxDS->getPortsForBuild( $build, $sort );
$ports_tree = $this->TinderboxDS->getPortsTreeById( $build->getPortsTreeId() );
$jail = $this->TinderboxDS->getJailById( $build->getJailId() );
@@ -57,6 +57,13 @@
$port_fail_reasons[$reason->getTag()]['type'] = $reason->getType();
}
+ $qs=array();
+ $qkvs=explode("&",$_SERVER["QUERY_STRING"]);
+ foreach ($qkvs as $qkv) {
+ $kv=explode("=",$qkv);
+ $qs[$kv[0]]=$kv[1];
+ }
+
$this->template_assign( 'port_fail_reasons', $port_fail_reasons );
$this->template_assign( 'maintainers', $this->TinderboxDS->getAllMaintainers() );
$this->template_assign( 'build_description', $build->getDescription() );
@@ -67,6 +74,7 @@
$this->template_assign( 'ports_tree_description', $ports_tree->getDescription() );
$this->template_assign( 'ports_tree_lastbuilt', $this->TinderboxDS->prettyDatetime( $ports_tree->getLastBuilt() ) );
$this->template_assign( 'local_time', $this->TinderboxDS->prettyDatetime( date( 'Y-m-d H:i:s' ) ) );
+ $this->template_assign( 'querystring', $qs);
return $this->template_parse( 'list_buildports.tpl' );
}
diff -ru www-exp-barnet/templates/default/list_buildports.tpl www-exp/templates/default/list_buildports.tpl
--- www-exp-barnet/templates/default/list_buildports.tpl Sun Dec 25 10:30:10 2005
+++ www-exp/templates/default/list_buildports.tpl Sun Dec 25 13:27:10 2005
@@ -38,17 +38,31 @@
</p>
</form>
-<?if(!$no_list){?>
+<?
+ if(!$no_list){
+?>
<table>
<tr>
- <th>Port Directory</th>
- <th>Maintainer</th>
- <th>Version</th>
+ <th>
+ <a href="<?= http_query($_SERVER["PHP_SELF"],$querystring,"sort","port_directory") ?>">Port Directory</a>
+ </th>
+ <th>
+ <a href="<?= http_query($_SERVER["PHP_SELF"],$querystring,"sort","port_maintainer") ?>">Maintainer</a>
+ </th>
+ <th>
+ <a href="<?= http_query($_SERVER["PHP_SELF"],$querystring,"sort","last_built_version") ?>">Version</a>
+ </th>
<th style="width: 20px"> </th>
- <th>Reason</th>
+ <th>
+ <a href="<?= http_query($_SERVER["PHP_SELF"],$querystring,"sort","last_fail_reason") ?>">Reason</a>
+ </th>
<th> </th>
- <th>Last Build Attempt</th>
- <th>Last Successful Build</th>
+ <th>
+ <a href="<?= http_query($_SERVER["PHP_SELF"],$querystring,"sort","last_built") ?>">Last Build Attempt</a>
+ </th>
+ <th>
+ <a href="<?= http_query($_SERVER["PHP_SELF"],$querystring,"sort","last_successful_built") ?>">Last Successful Build</a>
+ </th>
</tr>
<?foreach($data as $row) {?>
<tr>
-------------- next part --------------
diff -ru www-exp-barnet2/core/Build.php www-exp/core/Build.php
--- www-exp-barnet2/core/Build.php Sun Dec 25 13:35:13 2005
+++ www-exp/core/Build.php Sun Dec 25 14:18:56 2005
@@ -39,7 +39,8 @@
'Ports_Tree_Id' => '',
'Build_Description' => '',
'Build_Status' => '',
- 'Build_Current_Port' => ''
+ 'Build_Current_Port' => '',
+ 'Build_Last_Updated' => '',
);
$this->TinderObject($object_hash, $argv);
@@ -71,6 +72,10 @@
function getBuildCurrentPort() {
return $this->Build_Current_Port;
+ }
+
+ function getBuildLastUpdated() {
+ return $this->Build_Last_Updated;
}
function setName($name) {
diff -ru www-exp-barnet2/core/TinderboxDS.php www-exp/core/TinderboxDS.php
--- www-exp-barnet2/core/TinderboxDS.php Sun Dec 25 13:35:13 2005
+++ www-exp/core/TinderboxDS.php Sun Dec 25 14:35:34 2005
@@ -850,4 +850,14 @@
}
return "$url?$s";
}
+
+ function time_difference_from_now($then) {
+ $as=explode(" ",$then);
+ $ymd=explode("-",$as[0]);
+ $hms=explode(":",$as[1]);
+ $then=mktime($hms[0],$hms[1],$hms[2],$ymd[1],$ymd[2],$ymd[0]);
+ $diff=time()-$then;
+ return sprintf("%02d:%02d:%02d",
+ floor($diff/3600),floor(($diff%3600)/60),floor($diff%60));
+ }
?>
diff -ru www-exp-barnet2/module/moduleBuildPorts.php www-exp/module/moduleBuildPorts.php
--- www-exp-barnet2/module/moduleBuildPorts.php Sun Dec 25 13:35:13 2005
+++ www-exp/module/moduleBuildPorts.php Sun Dec 25 14:19:08 2005
@@ -167,6 +167,7 @@
$data[$i]['port_current_version'] = preparing_next_build;
$data[$i]['build_name'] = $build->getName();
+ $data[$i]['build_last_updated'] = $build->getBuildLastUpdated();
$i++;
}
$this->template_assign( 'data', $data );
diff -ru www-exp-barnet2/templates/default/current_buildports.tpl www-exp/templates/default/current_buildports.tpl
--- www-exp-barnet2/templates/default/current_buildports.tpl Sun Dec 25 13:35:13 2005
+++ www-exp/templates/default/current_buildports.tpl Sun Dec 25 14:19:34 2005
@@ -9,11 +9,13 @@
<tr>
<th>Build</th>
<th>Port</th>
+ <th>Duration</th>
</tr>
<?foreach($data as $row) {?>
<tr>
<td><a href="index.php?action=list_buildports&build=<?=$row['build_name']?>"><?=$row['build_name']?></a></td>
<td><?=$row['port_current_version']?></td>
+ <td><?=time_difference_from_now($row['build_last_updated'])?></td>
</tr>
<?}?>
</table>
diff -ru lib-barnet/Build.pm lib/Build.pm
--- lib-barnet/Build.pm Sun Dec 25 13:48:10 2005
+++ lib/Build.pm Sun Dec 25 13:59:34 2005
@@ -51,6 +51,7 @@
Build_Status => "",
Build_Description => "",
Build_Current_Port => "",
+ Build_Last_Updated => ""
};
my @args = ();
@@ -102,6 +103,12 @@
my $self = shift;
return $self->{Build_Current_Port};
+}
+
+sub getLastUpdated {
+ my $self = shift;
+
+ return $self->{Build_Last_Updated};
}
sub setName {
diff -ru lib-barnet/TinderboxDS.pm lib/TinderboxDS.pm
--- lib-barnet/TinderboxDS.pm Sun Dec 25 13:48:10 2005
+++ lib/TinderboxDS.pm Sun Dec 25 14:02:17 2005
@@ -1049,7 +1049,7 @@
croak "ERROR: Argument not of type build\n" if (ref($build) ne "Build");
my $rc =
- $self->_doQuery("UPDATE builds SET Build_Status=? WHERE Build_Id=?",
+ $self->_doQuery("UPDATE builds SET Build_Status=?,Build_Last_Updated='now' WHERE Build_Id=?",
[$build->getStatus(), $build->getId()]);
return $rc;
@@ -1065,12 +1065,12 @@
my $rc;
if (!defined($pkgname)) {
$rc = $self->_doQuery(
- "UPDATE builds SET Build_Current_Port=NULL WHERE Build_Id=?",
+ "UPDATE builds SET Build_Current_Port=NULL,Build_Last_Updated='now' WHERE Build_Id=?",
[$build->getId()]
);
} else {
$rc = $self->_doQuery(
- "UPDATE builds SET Build_Current_Port=? WHERE Build_Id=?",
+ "UPDATE builds SET Build_Current_Port=?,Build_Last_Updated='now' WHERE Build_Id=?",
[$pkgname, $build->getId()]
);
}
More information about the tinderbox-list
mailing list