Bugzilla – Attachment 3036 Details for
Bug 3154
OPAC Search refining by facets is wrong
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
patch.txt (text/plain), 5.05 KB, created by
Marcel de Rooy
on 2011-01-31 12:20:40 UTC
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2011-01-31 12:20:40 UTC
Size:
5.05 KB
patch
obsolete
>From e88b69b2df250679326e694384ffe4eba5dc5c8c Mon Sep 17 00:00:00 2001 >From: Fridolyn Somers <fridolyn.somers@gmail.com> >Date: Mon, 31 Jan 2011 13:10:10 +0100 >Subject: [PATCH] Bug 3154: OPAC Search refining by facets is wrong >Content-Type: text/plain; charset="utf-8" > >--- > C4/Search.pm | 74 ++++++++++++++++++++++++++++++++++++++------------------- > 1 files changed, 49 insertions(+), 25 deletions(-) > >diff --git a/C4/Search.pm b/C4/Search.pm >index dd41886..060bda4 100644 >--- a/C4/Search.pm >+++ b/C4/Search.pm >@@ -418,7 +418,6 @@ sub getRecords { > for ( my $j = $offset ; $j < $times ; $j++ ) { > my $records_hash; > my $record; >- my $facet_record; > > ## Check if it's an index scan > if ($scan) { >@@ -451,33 +450,58 @@ sub getRecords { > > # warn "RECORD $j:".$record; > $results_hash->{'RECORDS'}[$j] = $record; >- >- # Fill the facets while we're looping, but only for the biblioserver >- $facet_record = MARC::Record->new_from_usmarc($record) >- if $servers[ $i - 1 ] =~ /biblioserver/; >- >- #warn $servers[$i-1]."\n".$record; #.$facet_record->title(); >- if ($facet_record) { >- for ( my $k = 0 ; $k <= @$facets ; $k++ ) { >- ($facets->[$k]) or next; >- my @fields = map {$facet_record->field($_)} @{$facets->[$k]->{'tags'}} ; >- for my $field (@fields) { >- my @subfields = $field->subfields(); >- for my $subfield (@subfields) { >- my ( $code, $data ) = @$subfield; >- ($code eq $facets->[$k]->{'subfield'}) or next; >- $facets_counter->{ $facets->[$k]->{'link_value'} }->{$data}++; >- } >- } >- $facets_info->{ $facets->[$k]->{'link_value'} }->{'label_value'} = >- $facets->[$k]->{'label_value'}; >- $facets_info->{ $facets->[$k]->{'link_value'} }->{'expanded'} = >- $facets->[$k]->{'expanded'}; >- } >- } > } >+ > } > $results_hashref->{ $servers[ $i - 1 ] } = $results_hash; >+ >+ # Fill the facets while we're looping, but only for the biblioserver and not for a scan >+ if ( !$scan && $servers[ $i - 1 ] =~ /biblioserver/ ) { >+ >+ my $jmax = $size; >+ if ( $jmax > 500 ) { >+ $jmax = 500; # limit to 500 first records >+ } >+ >+ for ( my $k = 0 ; $k <= @$facets ; $k++ ) { >+ ($facets->[$k]) or next; >+ my @fcodes = @{$facets->[$k]->{'tags'}}; >+ my $sfcode = $facets->[$k]->{'subfield'}; >+ >+ for ( my $j = 0 ; $j < $jmax ; $j++ ) { >+ my $render_record = $results[ $i - 1 ]->record($j)->render(); >+ my @used_datas = (); >+ >+ foreach my $fcode (@fcodes) { >+ >+ # avoid first line >+ my $field_pattern = '\n'.$fcode.' ([^\n]+)'; >+ my @field_tokens = ( $render_record =~ /$field_pattern/g ) ; >+ >+ foreach my $field_token (@field_tokens) { >+ my $subfield_pattern = '\$'.$sfcode.' ([^\$]+)'; >+ my @subfield_values = ( $field_token =~ /$subfield_pattern/g ); >+ >+ foreach my $subfield_value (@subfield_values) { >+ >+ my $data = $subfield_value; >+ $data =~ s/^\s+//; # trim left >+ $data =~ s/\s+$//; # trim right >+ >+ unless ( $data ~~ @used_datas ) { >+ $facets_counter->{ $facets->[$k]->{'link_value'} }->{$data}++; >+ push @used_datas, $data; >+ } >+ } # subfields >+ } # fields >+ } # field codes >+ } # records >+ >+ $facets_info->{ $facets->[$k]->{'link_value'} }->{'label_value'} = $facets->[$k]->{'label_value'}; >+ $facets_info->{ $facets->[$k]->{'link_value'} }->{'expanded'} = $facets->[$k]->{'expanded'}; >+ } # facets >+ } >+ # End PROGILONE > } > > # warn "connection ", $i-1, ": $size hits"; >-- >1.6.0.6 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 3154
:
2696
|
3036
|
3201
|
3222
|
3223
|
3224
|
3332
|
3334