irspy_identifier2target
modify_xml_document
bib1_access_point
- render_record);
+ render_record
+ calc_reliability);
use XML::LibXML;
use XML::LibXML::XPathContext;
}
+sub calc_reliability {
+ my($xc) = @_;
+
+ my @allpings = $xc->findnodes("i:status/i:probe");
+ my $nall = @allpings;
+ return "[untested]" if $nall == 0;
+ my @okpings = $xc->findnodes('i:status/i:probe[@ok = "1"]');
+ my $nok = @okpings;
+ return "$nok/$nall = " . int(100*$nok/$nall) . "%";
+}
+
+
1;
irspy_xpath_context irspy_make_identifier
irspy_record2identifier
irspy_identifier2target modify_xml_document
- bib1_access_point);
+ bib1_access_point calc_reliability);
</%once>
% $r->content_type("text/html; charset=utf-8");
% my $text = $m->scomp($component, %ARGS);
return $url;
}
-# Identical to the same-named function in full.mc
-# So maybe this should go into IRSpy::Utils.pm?
-# Name changed (append 2) to prevent inadvertent clashes in Mason namespace
-#
-sub calc_reliability2 {
- my($xc) = @_;
-
- my @allpings = $xc->findnodes("i:status/i:probe");
- my $nall = @allpings;
- return "[untested]" if $nall == 0;
- my @okpings = $xc->findnodes('i:status/i:probe[@ok = "1"]');
- my $nok = @okpings;
- return "$nok/$nall = " . int(100*$nok/$nall) . "%";
-}
-
-
# Just make this once; forge the connection on first use
our $conn = undef;
</%once>
<%perl>
my $xc = irspy_xpath_context($rs->record($i-1));
my $title = $xc->find("e:databaseInfo/e:title") || "[UNTITLED]";
-my $reliability = calc_reliability2($xc);
+my $reliability = calc_reliability($xc);
my $host = $xc->find("e:serverInfo/e:host");
my $port = $xc->find("e:serverInfo/e:port");
my $db = $xc->find("e:serverInfo/e:database");
[ "Implementation ID" => "i:status/i:implementationId" ],
[ "Implementation Name" => "i:status/i:implementationName" ],
[ "Implementation Version" => "i:status/i:implementationVersion" ],
- [ "Reliability/reliability" => \&calc_reliability, $xc ],
+ [ "Reliability/reliability" => \&calc_reliability_wrapper, $xc ],
[ "Services" => \&calc_init_options, $xc ],
[ "Bib-1 Use attributes" => \&calc_ap, $xc, "bib-1" ],
[ "Dan-1 Use attributes" => \&calc_ap, $xc, "dan-1" ],
% }
<%perl>
-sub calc_reliability {
+sub calc_reliability_wrapper {
my($id, $xc) = @_;
-
- my @allpings = $xc->findnodes("i:status/i:probe");
- my $nall = @allpings;
- return "[untested]" if $nall == 0;
- my @okpings = $xc->findnodes('i:status/i:probe[@ok = "1"]');
- my $nok = @okpings;
- return "$nok/$nall = " . int(100*$nok/$nall) . "%";
+ return calc_reliability($xc);
}
sub calc_init_options {