[Koha-cvs] koha/z3950 search.pl [rel_2_2]
Henri-Damien LAURENT
laurenthdl at alinto.com
Mon Feb 26 16:24:01 CET 2007
CVSROOT: /sources/koha
Module name: koha
Branch: rel_2_2
Changes by: Henri-Damien LAURENT <hdl> 07/02/26 15:24:01
Modified files:
z3950 : search.pl
Log message:
A new search.pl that should be more reactive.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/z3950/search.pl?cvsroot=koha&only_with_tag=rel_2_2&r1=1.3.2.18&r2=1.3.2.19
Patches:
Index: search.pl
===================================================================
RCS file: /sources/koha/koha/z3950/search.pl,v
retrieving revision 1.3.2.18
retrieving revision 1.3.2.19
diff -u -b -r1.3.2.18 -r1.3.2.19
--- search.pl 26 Feb 2007 15:05:53 -0000 1.3.2.18
+++ search.pl 26 Feb 2007 15:24:01 -0000 1.3.2.19
@@ -146,23 +146,32 @@
}## while fetch
}# foreach
my $nremaining = $s;
+ my $firstresult=1;
+AGAIN:
my $k;
my $event;
+
while (($k = ZOOM::event(\@oConnection)) != 0) {
$event = $oConnection[$k-1]->last_event();
- warn ("connection ", $k-1, ": event $event (", ZOOM::event_str($event), ")\n");
- if ($event == ZOOM::Event::ZEND){
- my($error, $errmsg, $addinfo, $diagset) = $oConnection[$k-1]->error_x();
+ warn ("connection ", $k-1, ": event $event (", ZOOM::event_str($event), ")\n") if $DEBUG;
+ last if $event == ZOOM::Event::ZEND;
+ }
+
+ if ($k != 0) {
+ $k--;
+ warn $serverhost[$k] if $DEBUG;
+ my($error, $errmsg, $addinfo, $diagset) = $oConnection[$k]->error_x();
if ($error) {
- warn "$k $serverhost[$k - 1] error $query: $errmsg ($error) $addinfo\n";
- }else {
- my $numresults=$oResult[$k-1]->size() ;
+ warn "$k $serverhost[$k] error $query: $errmsg ($error) $addinfo\n" if $DEBUG;
+
+ } else {
+ my $numresults=$oResult[$k]->size() ;
my $i;
my $result='';
if ($numresults>0){
- for ($i=0; $i<($numresults>80?80:$numresults) ; $i++) {
- my $rec=$oResult[$k-1]->record($i);
+ for ($i=0; $i<(($numresults<20) ? ($numresults) : (20)) ; $i++) {
+ my $rec=$oResult[$k]->record($i);
my $marcrecord;
$marcdata = $rec->raw();
$marcrecord= fixEncoding($marcdata);
@@ -173,9 +182,7 @@
my $oldbiblio = MARCmarc2koha($dbh,$marcrecord,"");
$oldbiblio->{isbn} =~ s/ |-|\.//g,
$oldbiblio->{issn} =~ s/ |-|\.//g,
- my ($notmarcrecord,$alreadyindb,$alreadyinfarm,$imported,$bid)=ImportBreeding($marcdata,1,
- $serverhost[$k-1],$encoding[$k-1],$random);
-
+ my ($notmarcrecord,$alreadyindb,$alreadyinfarm,$imported,$breedingid)=ImportBreeding($marcdata,1,$serverhost[$k],$encoding[$k],$random);
my %row_data;
if ($i % 2) {
$toggle="#ffffcc";
@@ -183,26 +190,28 @@
$toggle="white";
}
$row_data{toggle} = $toggle;
- $row_data{server} = $serverhost[$k-1];
+ $row_data{server} = $serverhost[$k];
$row_data{isbn} = $oldbiblio->{isbn};
$row_data{title} =$oldbiblio->{title};
$row_data{author} = $oldbiblio->{author};
- $row_data{id} = $bid;
- $row_data{oldbiblionumber}=$biblionumber;
+ $row_data{breedingid} = $breedingid;
+ $row_data{biblionumber}=$biblionumber;
push (@breeding_loop, \%row_data);
- }
+ }# upto 5 results
}#$numresults
- else {
- warn "no results for $serverhost[$k - 1]";
}
- }
- }
-
- }
-
+ }# if $k !=0
+ $numberpending=$nremaining-1;
$template->param(breeding_loop => \@breeding_loop, server=>$serverhost[$k],
numberpending => $numberpending,
);
- output_html_with_http_headers $input, $cookie, $template->output;
+ output_html_with_http_headers $input, $cookie, $template->output if $numberpending==0;
+
+# print $template->output if $firstresult !=1;
+ $firstresult++;
+ MAYBE_AGAIN:
+ if (--$nremaining > 0) {
+ goto AGAIN;
+ }
} ## if op=search
More information about the Koha-cvs
mailing list