From: Mike Taylor Date: Mon, 12 Apr 2010 15:31:51 +0000 (+0100) Subject: Import calc_reliability_stats() and modify_xml_document(); X-Git-Tag: CPAN-v1.02~156 X-Git-Url: http://jsfdemo.indexdata.com/cgi-bin?a=commitdiff_plain;h=847531a8ed9aff2c7d50e17aa08c9f24fc28a265;p=irspy-moved-to-github.git Import calc_reliability_stats() and modify_xml_document(); _rewrite_zeerex_record() uses these to add new reliability field at e:metaInfo/i:reliability --- diff --git a/lib/ZOOM/IRSpy.pm b/lib/ZOOM/IRSpy.pm index d330113..2e90e79 100644 --- a/lib/ZOOM/IRSpy.pm +++ b/lib/ZOOM/IRSpy.pm @@ -18,7 +18,8 @@ use ZOOM::IRSpy::Connection; use ZOOM::IRSpy::Stats; use ZOOM::IRSpy::Utils qw(cql_target render_record irspy_xpath_context irspy_make_identifier - irspy_record2identifier); + irspy_record2identifier calc_reliability_stats + modify_xml_document); our @ISA = qw(); our $VERSION = '1.01'; @@ -305,9 +306,20 @@ sub _rewrite_irspy_record { } +my $_reliabilityField = { + reliability => [ reliability => 0, + "Calculated reliability of server", + "e:metaInfo/i:reliability" ], +}; + sub _rewrite_zeerex_record { my($conn, $rec, $oldid) = @_; + # Add reliability score + my $xc = irspy_xpath_context($rec); + my($nok, $nall, $percent) = calc_reliability_stats($xc); + modify_xml_document($xc, $_reliabilityField, { reliability => $percent }); + my $p = $conn->package(); $p->option(action => "specialUpdate"); my $xml = $rec->toString(); @@ -317,7 +329,6 @@ sub _rewrite_zeerex_record { # This is the expression in the ID-making stylesheet # ../../zebra/zeerex2id.xsl - my $xc = irspy_xpath_context($rec); my $id = irspy_record2identifier($xc); if (defined $oldid && $id ne $oldid) { warn "IDs differ (old='$oldid' new='$id')";