Bug 20919: Remove unecessary search calls on the biblio detail page

There is a countanalytics flag that is set for items used in analytical
biblio records. This flag is only used in the template when 'analyze'
has been passed to the script.
In order to avoid unecessary search calls (1 per item), $analyse must be
tested.

Test plan:
0. Do not apply the patch
1. tail -f /var/log/koha/kohadev/zebra-output.log
2. Hit a bibliographic record detail page with several items
3. Notice that the log has 1 line per item:
  11:30:36-14/06 zebrasrv(32) [warn] ir_session (exception)
4. Apply the patch
5. Hit the page again
6. There is nothing in the zebra log file

If you are familiar with analytic records, confirm that you are not
allowed to remove an item that is used in analytical biblio records.

Signed-off-by: Hugo Agud <hagud@orex.es>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
(cherry picked from commit e4b51adb9a)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
Jonathan Druart 2018-06-14 11:31:02 -03:00 committed by Fridolin Somers
parent f09fbab4c8
commit b470ea71cc
1 changed files with 9 additions and 5 deletions

View File

@ -302,11 +302,15 @@ foreach my $item (@items) {
$item->{hosttitle} = GetBiblioData($item->{biblionumber})->{title};
}
#count if item is used in analytical bibliorecords
my $countanalytics = C4::Context->preference('EasyAnalyticalRecords') ? GetAnalyticsCount($item->{itemnumber}) : 0;
if ($countanalytics > 0){
$analytics_flag=1;
$item->{countanalytics} = $countanalytics;
if ( $analyze ) {
# count if item is used in analytical bibliorecords
# The 'countanalytics' flag is only used in the templates if analyze is set
my $countanalytics = C4::Context->preference('EasyAnalyticalRecords') ? GetAnalyticsCount($item->{itemnumber}) : 0;
if ($countanalytics > 0){
$analytics_flag=1;
$item->{countanalytics} = $countanalytics;
}
}
if (defined($item->{'materials'}) && $item->{'materials'} =~ /\S/){