From 2d15dcabc8503f8131adb3e549f4e0c49e9afaa7 Mon Sep 17 00:00:00 2001 From: Henri-Damien LAURENT Date: Wed, 21 Oct 2009 16:39:35 +0200 Subject: [PATCH] Performance improvement authorities-list.pl CountUsage in Authorities has a performance problem. We now rely on SimpleSarch for that purpose and it should be better --- C4/AuthoritiesMarc.pm | 10 +--------- authorities/authorities-list.pl | 9 +++++++-- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm index a4237387c5..501ff09aa1 100644 --- a/C4/AuthoritiesMarc.pm +++ b/C4/AuthoritiesMarc.pm @@ -361,17 +361,9 @@ sub CountUsage { return scalar @tab; } else { ### ZOOM search here - my $oConnection=C4::Context->Zconn("biblioserver",1); my $query; $query= "an=".$authid; - my $oResult = $oConnection->search(new ZOOM::Query::CCL2RPN( $query, $oConnection )); - my $result; - while ((my $i = ZOOM::event([ $oConnection ])) != 0) { - my $ev = $oConnection->last_event(); - if ($ev == ZOOM::Event::ZEND) { - $result = $oResult->size(); - } - } + my ($err,$res,$result) = C4::Search::SimpleSearch($query,0,10); return ($result); } } diff --git a/authorities/authorities-list.pl b/authorities/authorities-list.pl index 435948921d..9c472f13f2 100644 --- a/authorities/authorities-list.pl +++ b/authorities/authorities-list.pl @@ -4,6 +4,8 @@ use warnings; use C4::Context; use C4::AuthoritiesMarc; use utf8; +use open qw( :std :utf8 ); + my $dbh=C4::Context->dbh; my $datatypes_query = $dbh->prepare(<execute; my $dataauthorities=$data_query->fetchall_arrayref({}); -print "id;authtype;heading;count usage\n"; foreach my $authority (@$dataauthorities){ my $marcauthority=GetAuthority($authority->{'authid'}); + my $query; + $query= "an=".$authority->{'authid'}; + # search for biblios mapped + my ($err,$res,$used) = C4::Search::SimpleSearch($query,0,10); if ($marcauthority && $marcauthority->field($authtypes{$authority->{'authtypecode'}}->{'tag'})){ - print qq($authority->{'authid'};"),$authtypes{$authority->{'authtypecode'}}->{'lib'},qq(";"),$marcauthority->field($authtypes{$authority->{'authtypecode'}}->{"tag"})->as_string(),qq(";), CountUsage($authority->{authid}),"\n"; + print qq("),$marcauthority->field($authtypes{$authority->{'authtypecode'}}->{"tag"})->as_string(),qq(";),qq($authority->{'authid'};"),$authtypes{$authority->{'authtypecode'}}->{'lib'},qq(";$used\n); } } -- 2.39.5