From a120ebcc32ca28c2b046e80f13d2de6609bb98c4 Mon Sep 17 00:00:00 2001 From: Mike Taylor Date: Mon, 12 Apr 2010 16:31:51 +0100 Subject: [PATCH] Import calc_reliability_stats() and modify_xml_document(); _rewrite_zeerex_record() uses these to add new reliability field at e:metaInfo/i:reliability --- lib/ZOOM/IRSpy.pm | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) 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')"; -- 1.7.10.4