&GetAuthority
&GetAuthorityXML
- &CountUsage
- &CountUsageChildren
&SearchAuthorities
&BuildSummary
###
if (! $skipmetadata) {
for (my $z=0; $z<@finalresult; $z++){
- my $count=CountUsage($finalresult[$z]{authid});
+ my $count = Koha::Authorities->get_usage_count({ authid => $finalresult[$z]{authid} });
$finalresult[$z]{used}=$count;
}# all $z's
}
return (\@finalresult, $nbresults);
}
-=head2 CountUsage
-
- $count= &CountUsage($authid)
-
-counts Usage of Authid in bibliorecords.
-
-=cut
-
-sub CountUsage {
- my ($authid) = @_;
- ### ZOOM search here
- my $query;
- $query= "an:".$authid;
- # Should really be replaced with a real count call, this is a
- # bad way.
- my $searcher = Koha::SearchEngine::Search->new({index => $Koha::SearchEngine::BIBLIOS_INDEX});
- my ($err,$res,$result) = $searcher->simple_search_compat($query,0,1);
- if ($err) {
- warn "Error: $err from search $query";
- $result = 0;
- }
-
- return $result;
-}
-
-=head2 CountUsageChildren
-
- $count= &CountUsageChildren($authid)
-
-counts Usage of narrower terms of Authid in bibliorecords.
-
-=cut
-
-sub CountUsageChildren {
- my ($authid) = @_;
-}
-
=head2 GuessAuthTypeCode
my $authtypecode = GuessAuthTypeCode($record);
$template->{VARS}->{'loophierarchies'} = GenerateHierarchy($authid);
}
-my $count = CountUsage($authid);
+my $count = $authobj ? $authobj->get_usage_count : 0;
# find the marc field/subfield used in biblio by this authority
my $sth = $dbh->prepare("select distinct tagfield from marc_subfield_structure where authtypecode=?");
}
my $authority = Koha::Authorities->find( $authid );
-my $authtypecode = $authority->authtypecode;
+my $authtypecode = $authority ? $authority->authtypecode : q{};
if ($display_hierarchy){
$template->{VARS}->{'displayhierarchy'} = $display_hierarchy;
$template->{VARS}->{'loophierarchies'} = GenerateHierarchy($authid);
}
-my $count = CountUsage($authid);
+my $count = $authority ? $authority->get_usage_count : 0;
my $authority_types = Koha::Authority::Types->search( {}, { order_by => ['authtypecode'] } );
$template->param(
);
};
-subtest 'Trivial tests for get_count_usage and linked_biblionumbers' => sub {
+subtest 'Trivial tests for get_usage_count and linked_biblionumbers' => sub {
plan tests => 5;
# NOTE: We are not testing $searcher->simple_search_compat here. Suppose
use C4::AuthoritiesMarc;
use C4::Biblio;
+use Koha::Authorities;
use Koha::Biblios;
my $input = new CGI;
$authority = {
authid => $record_id,
summary => C4::AuthoritiesMarc::BuildSummary( $authority, $record_id ),
- count_usage => C4::AuthoritiesMarc::CountUsage( $record_id ),
+ count_usage => Koha::Authorities->get_usage_count({ authid => $record_id }),
};
push @records, $authority;
}