Bugzilla – Attachment 65653 Details for
Bug 18149
Move CountUsage calls to Koha namespace
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[SIGNED-OFF] Bug 18149: Move CountUsage calls to Koha namespace
SIGNED-OFF-Bug-18149-Move-CountUsage-calls-to-Koha.patch (text/plain), 6.18 KB, created by
Josef Moravec
on 2017-08-08 14:46:40 UTC
(
hide
)
Description:
[SIGNED-OFF] Bug 18149: Move CountUsage calls to Koha namespace
Filename:
MIME Type:
Creator:
Josef Moravec
Created:
2017-08-08 14:46:40 UTC
Size:
6.18 KB
patch
obsolete
>From 385627f36c52f79167a8ba0bafb4844a33db8e5c Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Thu, 29 Jun 2017 13:03:39 +0200 >Subject: [PATCH] [SIGNED-OFF] Bug 18149: Move CountUsage calls to Koha > namespace > >After the introduction of Koha::Authorities->get_usage_count with bug >9988, we can now replace the remaining occurrences of CountUsage. > >At the same time we remove CountUsageChildren. This was an empty sub. >The typo get_count_usage in a subtest title is adjusted. > >Test plan: >[1] Run t/db_dependent/Koha/Authorities.t >[2] Perform a search on authorities-home.pl and verify that you see > plausible numbers for 'used in xx records'. >[3] Click on Details for one authority. See the same number? >[4] Do the same as in 2/3 for Authority search on OPAC. >[5] Remember the authid and enter this in the record numbers box on > tools/batch_delete_records.pl. Select Authorities and click > Continue. The next form shows a column "Used in". Do you see > the same count again? >[6] Git grep CountUsage. > You should see just one hit in a comment that can be kept in > Koha/Authorities.pm. > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> > >Signed-off-by: Josef Moravec <josef.moravec@gmail.com> >--- > C4/AuthoritiesMarc.pm | 41 +-------------------------------------- > authorities/detail.pl | 5 +++-- > opac/opac-authoritiesdetail.pl | 4 ++-- > t/db_dependent/Koha/Authorities.t | 2 +- > tools/batch_delete_records.pl | 3 ++- > 5 files changed, 9 insertions(+), 46 deletions(-) > >diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm >index 9f1f284..5a04087 100644 >--- a/C4/AuthoritiesMarc.pm >+++ b/C4/AuthoritiesMarc.pm >@@ -51,8 +51,6 @@ BEGIN { > &GetAuthority > &GetAuthorityXML > >- &CountUsage >- &CountUsageChildren > &SearchAuthorities > > &BuildSummary >@@ -327,7 +325,7 @@ sub SearchAuthorities { > ### > 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 > } >@@ -340,43 +338,6 @@ sub SearchAuthorities { > 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); >diff --git a/authorities/detail.pl b/authorities/detail.pl >index 38af541..22e0aaf 100755 >--- a/authorities/detail.pl >+++ b/authorities/detail.pl >@@ -178,7 +178,8 @@ my ($template, $loggedinuser, $cookie) = get_template_and_user( > > my $authid = $query->param('authid'); > >-my $authtypecode = Koha::Authorities->find($authid)->authtypecode; >+my $authobj = Koha::Authorities->find($authid); >+my $authtypecode = $authobj ? $authobj->authtypecode: q{}; > $tagslib = &GetTagsLabels(1,$authtypecode); > > # Build list of authtypes for showing them >@@ -200,7 +201,7 @@ if (C4::Context->preference("AuthDisplayHierarchy")){ > $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=?"); >diff --git a/opac/opac-authoritiesdetail.pl b/opac/opac-authoritiesdetail.pl >index f46c511..438ef80 100755 >--- a/opac/opac-authoritiesdetail.pl >+++ b/opac/opac-authoritiesdetail.pl >@@ -77,14 +77,14 @@ if ( ! $record ) { > } > > 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( >diff --git a/t/db_dependent/Koha/Authorities.t b/t/db_dependent/Koha/Authorities.t >index 501e62b..9fa6c73 100644 >--- a/t/db_dependent/Koha/Authorities.t >+++ b/t/db_dependent/Koha/Authorities.t >@@ -127,7 +127,7 @@ subtest 'Testing reporting_tag_xml in MergeRequest' => sub { > ); > }; > >-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 >diff --git a/tools/batch_delete_records.pl b/tools/batch_delete_records.pl >index 4be2427..c621623 100755 >--- a/tools/batch_delete_records.pl >+++ b/tools/batch_delete_records.pl >@@ -28,6 +28,7 @@ use C4::Output; > use C4::AuthoritiesMarc; > use C4::Biblio; > >+use Koha::Authorities; > use Koha::Biblios; > > my $input = new CGI; >@@ -101,7 +102,7 @@ if ( $op eq 'form' ) { > $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; > } >-- >2.1.4
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 18149
:
64720
|
65653
|
66984