[Koha-cvs] CVS: koha/C4 SearchMarc.pm,1.23,1.24
Paul POULAIN
tipaul at users.sourceforge.net
Fri Aug 20 10:19:54 CEST 2004
Update of /cvsroot/koha/koha/C4
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18662/C4
Modified Files:
SearchMarc.pm
Log Message:
fixing a complex bug : the last results didn't have callnumber informations. Had to rewrite algorythm for building the result array.
Index: SearchMarc.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/SearchMarc.pm,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -r1.23 -r1.24
*** SearchMarc.pm 18 Aug 2004 16:44:37 -0000 1.23
--- SearchMarc.pm 20 Aug 2004 08:19:52 -0000 1.24
***************
*** 143,147 ****
{
# remove the "%" for small word (3 letters. (note : the >4 is due to the % at the end)
! warn "word : $word";
$word =~ s/%//g unless length($word)>4;
unless (C4::Context->stopwords->{uc($word)}) { #it's NOT a stopword => use it. Otherwise, ignore
--- 143,147 ----
{
# remove the "%" for small word (3 letters. (note : the >4 is due to the % at the end)
! # warn "word : $word";
$word =~ s/%//g unless length($word)>4;
unless (C4::Context->stopwords->{uc($word)}) { #it's NOT a stopword => use it. Otherwise, ignore
***************
*** 168,172 ****
{
# remove the "%" for small word (3 letters. (note : the >4 is due to the % at the end)
! warn "word : $word";
$word =~ s/%//g unless length($word)>4;
unless (C4::Context->stopwords->{uc($word)}) { #it's NOT a stopword => use it. Otherwise, ignore
--- 168,172 ----
{
# remove the "%" for small word (3 letters. (note : the >4 is due to the % at the end)
! # warn "word : $word";
$word =~ s/%//g unless length($word)>4;
unless (C4::Context->stopwords->{uc($word)}) { #it's NOT a stopword => use it. Otherwise, ignore
***************
*** 251,255 ****
# we have bibid list. Now, loads title and author from [offset] to [offset]+[length]
my $counter = $offset;
! $sth = $dbh->prepare("SELECT biblio.*, biblioitems.*, items.*,marc_biblio.bibid
FROM biblio, marc_biblio
LEFT JOIN items on items.biblionumber = biblio.biblionumber
--- 251,255 ----
# we have bibid list. Now, loads title and author from [offset] to [offset]+[length]
my $counter = $offset;
! $sth = $dbh->prepare("SELECT biblio.biblionumber as bn,biblio.*, biblioitems.*, items.*,marc_biblio.bibid
FROM biblio, marc_biblio
LEFT JOIN items on items.biblionumber = biblio.biblionumber
***************
*** 263,273 ****
my $oldline;
# my ($biblionumber,$author,$title,$holdingbranch, $itemcallnumber, $bibid);
! my ($oldbibid, $oldauthor, $oldtitle,$oldbiblionumber);
while (($counter <= $#result) && ($counter <= ($offset + $length))) {
$sth->execute($result[$counter]);
! while (my $line = $sth->fetchrow_hashref) {
# parse the result, putting holdingbranch & itemcallnumber in separate array
# then all other fields in the main array
! if ($oldbiblionumber && ($oldbiblionumber ne $line->{biblionumber})) {
my %newline;
%newline = %$oldline;
--- 263,279 ----
my $oldline;
# my ($biblionumber,$author,$title,$holdingbranch, $itemcallnumber, $bibid);
! my ($oldbibid, $oldauthor, $oldtitle);
! # parse all biblios between start & end.
while (($counter <= $#result) && ($counter <= ($offset + $length))) {
+ # warn " bibid :".$result[$counter];
+ # search & parse all items & note itemcallnumber
$sth->execute($result[$counter]);
! my $continue=1;
! my $line = $sth->fetchrow_hashref;
! $continue=0 unless $line;
! while ($continue) {
# parse the result, putting holdingbranch & itemcallnumber in separate array
# then all other fields in the main array
! if ($oldbiblionumber && ($oldbiblionumber ne $line->{bn}) && $oldline) {
my %newline;
%newline = %$oldline;
***************
*** 282,313 ****
$totalitems=0;
}
! $oldbiblionumber = $line->{biblionumber};
! $totalitems++ if ($line->{holdingbranch});
! $oldline = $line;
! # item callnumber & branch
! my %lineCN;
! $lineCN{holdingbranch} = $line->{holdingbranch};
! $lineCN{itemcallnumber} = $line->{itemcallnumber};
! push @CNresults,\%lineCN;
}
$counter++;
}
! # add the last line, that is not reached byt the loop / if ($oldbiblionumber...)
! my %newline;
! if ($oldline) {
! %newline = %$oldline;
! $newline{totitem} = $totalitems;
! $newline{biblionumber} = $oldbiblionumber;
! my @CNresults2= @CNresults;
! $newline{CN} = \@CNresults2;
! $newline{'even'} = 1 if $counter % 2 == 0;
! $newline{'odd'} = 1 if $counter % 2 == 1;
! @CNresults = ();
! my @CNresults2= @CNresults;
! $newline{CN} = \@CNresults2;
! @CNresults = ();
! push @finalresult, \%newline;
! }
! my $nbresults = $#result + 1;
return (\@finalresult, $nbresults);
}
--- 288,308 ----
$totalitems=0;
}
! $continue=0 unless $line;
! if ($continue) {
! $oldbiblionumber = $line->{bn};
! $totalitems++ if ($line->{holdingbranch});
! $oldline = $line;
! # item callnumber & branch
! my %lineCN;
! $lineCN{holdingbranch} = $line->{holdingbranch};
! $lineCN{itemcallnumber} = $line->{itemcallnumber};
! push @CNresults,\%lineCN;
! $line = $sth->fetchrow_hashref;
! }
}
$counter++;
}
! #add the last line, that is not reached byt the loop / if ($oldbiblionumber...)
! my $nbresults = $#result+1;
return (\@finalresult, $nbresults);
}
More information about the Koha-cvs
mailing list