1 %# $Id: found.mc,v 1.33 2009-04-15 18:16:46 wosch Exp $
4 my($params, $cond, $caption, $skip) = @_;
7 print(' <a href="', navlink($params, $caption, $skip),
8 '"', ">$caption</a>\n");
10 print qq[ <span class="disabled">$caption</span>\n];
15 my($params, $caption, $skip) = @_;
16 local $params->{_skip} = $skip;
17 my $url = "?" . join("&", map { "$_=" . $params->{$_} } sort keys %$params);
18 $url = xml_encode($url);
22 # Identical to the same-named function in full.mc
23 # So maybe this should go into IRSpy::Utils.pm?
24 # Name changed (append 2) to prevent inadvertent clashes in Mason namespace
26 sub calc_reliability2 {
29 my @allpings = $xc->findnodes("i:status/i:probe");
31 return "[untested]" if $nall == 0;
32 my @okpings = $xc->findnodes('i:status/i:probe[@ok = "1"]');
34 return "$nok/$nall = " . int(100*$nok/$nall) . "%";
38 # Just make this once; forge the connection on first use
42 my %params = map { ( $_, utf8param($r, $_)) } grep { &utf8param($r, $_) } &utf8param($r);
44 if ($params{_query}) {
45 $query = $params{_query};
48 foreach my $key (keys %params) {
50 my $val = $params{$key};
52 $query .= " and " if $query ne "";
53 $query .= "$key = ($val)";
56 $query = 'cql.allRecords=1' if $query eq "";
58 my $sort = $params{"_sort"};
61 if ($sort =~ s/(\/.*)//) {
64 $query .= " or $sort=/sort";
65 $query .= "-desc" if $params{_desc};
70 my $tried_to_open = 0;
73 $conn = new ZOOM::Connection("localhost:8018/IR-Explain---1");
74 $conn->option(elementSetName => "zeerex");
75 $conn->option(count => 20);
79 eval { $rs = $conn->search(new ZOOM::Query::CQL($query)) };
80 if ($@ && ref $@ && $@->isa('ZOOM::Exception') &&
81 $@->code() == ZOOM::Error::CONNECTION_LOST && !$tried_to_open) {
90 my $skip = $params{"_skip"} || 0;
91 my $count = $params{"_count"} || 10;
94 my $last = $first+$count-1;
95 $last = $n if $last > $n;
97 <form method="get" action=""><p>
98 <input type="text" name="_query" size="60" value="<% xml_encode($query) %>"/>
99 <input type="submit" name="_search" value="Search"/>
104 % } elsif ($first > $n) {
106 Past end of <% $n %> records
108 Records <% $first %> to <% $last %> of <% $n %><br/>
110 print_navlink(\%params, $skip > 0, "Prev", $count < $skip ? $skip-$count : 0);
111 print_navlink(\%params, $last < $n, "Next", $skip+$count);
115 % if ($n > 0 && $first <= $n) {
120 <th>Host Connection Reliability <& /help/link.mc, help => "info/reliability" &>
129 % $rs->records($first-1, $last-$first+1); ## Force pre-cache
130 % foreach my $i ($first .. $last) {
132 my $xc = irspy_xpath_context($rs->record($i-1));
133 my $title = $xc->find("e:databaseInfo/e:title") || "[UNTITLED]";
134 my $reliability = calc_reliability2($xc);
135 my $host = $xc->find("e:serverInfo/e:host");
136 my $port = $xc->find("e:serverInfo/e:port");
137 my $db = $xc->find("e:serverInfo/e:database");
138 my $id = irspy_record2identifier($xc);
141 <tr style="background: <% ($i % 2) ? '#ffffc0' : 'white' %>">
143 <td><a href="<% xml_encode("/full.html?id=" . uri_escape($id))
144 %>"><% xml_encode($title) %></a></td>
145 <td><% xml_encode($reliability, "", { nbsp => 1 }) %></td>
146 <td><% xml_encode($host, "") %></td>
147 <td><% xml_encode($port, "") %></td>
148 <td><% xml_encode($db, "") %></td>
150 <a href="<% xml_encode("/admin/check.html?id=" . uri_escape($id))
151 %>" title="Test this target">Test</a
152 > <a href="<% xml_encode("/admin/edit.html?op=edit&id=" .
154 %>" title="Edit this target's record">Edit</a
155 > <a href="<% xml_encode("/raw.html?id=" . uri_escape($id))
156 %>" title="Raw XML record">XML</a>
162 print_navlink(\%params, $skip > 0, "Prev", $count < $skip ? $skip-$count : 0);
163 print_navlink(\%params, $last < $n, "Next", $skip+$count);
166 <a href="<% "/admin/check.html?" .
167 xml_encode(join("&", map { "id=" . uri_escape($_) } @ids))
168 %>">[Test all targets on this list]</a>
171 <a href="<% "/stats.html?query=" . xml_encode(uri_escape($query))
172 %>">[Statistics for targets on this list]</a>