Minor adjustments
[buildfarm-server.git] / cgi-bin / show_log.pl
index 9173f5b6520d6c5ba9ec1be99786566d96fdfc23..7fea634bad0a3aef839a78217ce58c53aaf6a10f 100755 (executable)
@@ -38,6 +38,7 @@ my $conf = "";
 my ($stage,$changed_this_run,$changed_since_success,$sysinfo,$branch,$scmurl);
 my $scm;
 my ($git_head_ref, $last_build_git_ref, $last_success_git_ref);
+my ($stage_times, $run_time);
 
 use vars qw($info_row);
 
@@ -57,16 +58,20 @@ if ($system && $logdate)
 
        };
        my $last_build_statement = q{
-               select distinct on (sysname) sysname, snapshot, stage, git_head_ref 
-        from build_status 
-        where sysname = ? and branch = ? and snapshot < ? 
-        order by sysname, snapshot desc limit 1
+               select git_head_ref 
+                from build_status 
+                where sysname = ? and branch = ?  and snapshot =
+                    (select max(snapshot)
+                    from build_status
+                    where sysname = ? and branch = ? and snapshot < ?)
        };
        my $last_success_statement = q{
-               select distinct on (sysname) sysname, snapshot, git_head_ref 
-        from build_status 
-        where sysname = ? and branch = ? and snapshot < ? and stage = 'OK' 
-        order by sysname, snapshot desc limit 1
+               select git_head_ref 
+                from build_status 
+                where sysname = ? and branch = ?  and snapshot =
+                    (select max(snapshot)
+                    from build_status
+                    where sysname = ? and branch = ? and snapshot < ? and stage = 'OK')
        };
        my $sth=$db->prepare($statement);
        $sth->execute($system,$logdate);
@@ -79,7 +84,7 @@ if ($system && $logdate)
        {
                $last_build_row = 
                  $db->selectrow_hashref($last_build_statement,undef,
-                                                                $system,$branch,$logdate);
+                                                                $system, $branch,$system,$branch,$logdate);
                $last_build_git_ref = $last_build_row->{git_head_ref}
                  if $last_build_row;
                
@@ -89,7 +94,7 @@ if ($system && $logdate)
        {
                $last_success_row =
                  $db->selectrow_hashref($last_success_statement,undef,
-                                                                $system,$branch,$logdate);
+                                                                $system,$branch,$system,$branch,$logdate);
                $last_success_git_ref = $last_success_row->{git_head_ref}
                  if $last_success_row;
        }
@@ -102,6 +107,9 @@ if ($system && $logdate)
        $scm = $row->[7];
        $scm ||= 'cvs'; # legacy scripts
        $scmurl = $row->[8];
+       $scmurl = undef unless $scmurl =~ /^http/; # slight sanity check
+       $scmurl = 'http://git.postgresql.org/gitweb?p=postgresql.git;a=commit;h=' 
+           if ($scmurl eq 'http://git.postgresql.org/git/postgresql.git');
        $log_file_names =~ s/^\{(.*)\}$/$1/;
        @log_file_names=split(',',$log_file_names)
            if $log_file_names;
@@ -111,7 +119,7 @@ if ($system && $logdate)
           select operating_system, os_version, 
                  compiler, compiler_version, 
                  architecture,
-                replace(owner_email,'\@',' [ a t ] ') as owner_email,
+                replace(owner_email,E'\@',' [ a t ] ') as owner_email,
                 sys_notes_ts::date AS sys_notes_date, sys_notes
           from buildsystems 
           where status = 'approved'
@@ -135,6 +143,21 @@ if ($system && $logdate)
            $info_row->{compiler_version} = $latest_personality->[1];
        }
        $sth->finish;
+       my $stage_times_query = q{
+           select log_stage, stage_duration
+           from build_status_log
+           where sysname = ? and snapshot = ?
+        };
+       $stage_times = 
+           $db->selectall_hashref($stage_times_query,'log_stage',undef,
+                                  $system,$logdate);
+       $stage_times_query = q{
+           select sum(stage_duration)
+           from build_status_log
+           where sysname = ? and snapshot = ?
+        };
+       ($run_time) = $db->selectrow_array($stage_times_query,undef,
+                                  $system,$logdate);
        $db->disconnect;
 }
 
@@ -157,6 +180,8 @@ $template->process('log.tt',
                system => $system,
                branch => $branch,
                stage => $stage,
+               stage_times => $stage_times,
+               run_time => $run_time,
                urldt => $logdate,
                log_file_names => \@log_file_names,
                conf => $conf,