X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=lib%2FZOOM%2FIRSpy%2FUtils.pm;h=0583662150e0b055de3d304231778708cac7704a;hb=32f8933db25356a6d5c742530e70c7b4ae4f97e2;hp=475e9deeda19ed7aa5ac076a61cd6cdcaf27dbeb;hpb=18fb57abfe6c3aa71788d4b2d4296b9f8a1843c0;p=irspy-moved-to-github.git diff --git a/lib/ZOOM/IRSpy/Utils.pm b/lib/ZOOM/IRSpy/Utils.pm index 475e9de..0583662 100644 --- a/lib/ZOOM/IRSpy/Utils.pm +++ b/lib/ZOOM/IRSpy/Utils.pm @@ -163,7 +163,7 @@ sub cql_quote { my($term) = @_; $term =~ s/([""\\*?])/\\$1/g; - $term = qq["$term"] if $term =~ /[\s""\/]/; + $term = qq["$term"] if $term =~ /[\s""\/\\]/; return $term; } @@ -180,8 +180,7 @@ sub cql_target { $id = $protocol; } - return "rec.id=" . cql_quote($id); - #return "rec.id_raw=" . cql_quote($id); + return "rec.id==" . cql_quote($id); } @@ -814,11 +813,21 @@ sub calc_reliability_string { sub calc_reliability_stats { my($xc) = @_; + my $sixtyDaysAgo = time() - 60*24*60*60; + my $iso60DA = isodate($sixtyDaysAgo); my @allpings = $xc->findnodes("i:status/i:probe"); - my $nall = @allpings; + + my($nall, $nok) = (0, 0); + foreach my $node (@allpings) { + my $ok = $xc->findvalue('@ok', $node); + my $when = $node->to_literal(); + #warn "$when cmp $iso60DA == ", ($when cmp $iso60DA), "\n"; + next if $when lt $iso60DA; + $nall++; + $nok += !!$ok; + } + return (0, 0, 0) if $nall == 0; - my @okpings = $xc->findnodes('i:status/i:probe[@ok = "1"]'); - my $nok = @okpings; my $percent = int(100*$nok/$nall + 0.5); return ($nok, $nall, $percent); }