Bugzilla – Attachment 45930 Details for
Bug 15295
Move the C4::Branch related code to Koha::Libraries - part 2
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 15295: Koha::Libraries - Remove GetBranchesCount
Bug-15295-KohaLibraries---Remove-GetBranchesCount.patch (text/plain), 5.02 KB, created by
Martin Renvoize (ashimema)
on 2015-12-23 05:16:20 UTC
(
hide
)
Description:
Bug 15295: Koha::Libraries - Remove GetBranchesCount
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2015-12-23 05:16:20 UTC
Size:
5.02 KB
patch
obsolete
>From e6efcf1fc4d1c0adda0831403101897beb886ecd Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 3 Dec 2015 14:47:50 +0000 >Subject: [PATCH] Bug 15295: Koha::Libraries - Remove GetBranchesCount >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >This is replaced with Koha::Libraries->search->count. > >Signed-off-by: Marc Véron <veron@veron.ch> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> > >http://bugs.koha-community.org/show_bug.cgi?id=15294 >--- > C4/Branch.pm | 10 ---------- > C4/Koha.pm | 7 ++++--- > t/db_dependent/Branch.t | 16 ++++++++-------- > 3 files changed, 12 insertions(+), 21 deletions(-) > >diff --git a/C4/Branch.pm b/C4/Branch.pm >index e6c4853..c4e4cc1 100644 >--- a/C4/Branch.pm >+++ b/C4/Branch.pm >@@ -40,7 +40,6 @@ BEGIN { > &GetBranchesInCategory > &ModBranchCategoryInfo > &mybranch >- &GetBranchesCount > ); > @EXPORT_OK = qw( &onlymine &mybranch ); > } >@@ -403,15 +402,6 @@ sub ModBranchCategoryInfo { > $sth->execute($data->{'categoryname'}, $data->{'codedescription'},$data->{'categorytype'},$data->{'show_in_pulldown'},uc( $data->{'categorycode'} ) ); > } > } >-sub GetBranchesCount { >- my $dbh = C4::Context->dbh(); >- my $query = "SELECT COUNT(*) AS branches_count FROM branches"; >- my $sth = $dbh->prepare( $query ); >- $sth->execute(); >- my $row = $sth->fetchrow_hashref(); >- return $row->{'branches_count'}; >-} >- > 1; > __END__ > >diff --git a/C4/Koha.pm b/C4/Koha.pm >index 7476106..3fc4fa5 100644 >--- a/C4/Koha.pm >+++ b/C4/Koha.pm >@@ -24,9 +24,10 @@ use strict; > #use warnings; FIXME - Bug 2505 > > use C4::Context; >-use C4::Branch qw(GetBranchesCount); >+use C4::Branch; # Can be removed? > use Koha::Cache; > use Koha::DateUtils qw(dt_from_string); >+use Koha::Libraries; > use DateTime::Format::MySQL; > use Business::ISBN; > use autouse 'Data::cselectall_arrayref' => qw(Dumper); >@@ -857,7 +858,7 @@ sub getFacets { > ]; > > unless ( C4::Context->preference("singleBranchMode") >- || GetBranchesCount() == 1 ) >+ || Koha::Libraries->search->count == 1 ) > { > my $DisplayLibraryFacets = C4::Context->preference('DisplayLibraryFacets'); > if ( $DisplayLibraryFacets eq 'both' >@@ -939,7 +940,7 @@ sub getFacets { > ]; > > unless ( C4::Context->preference("singleBranchMode") >- || GetBranchesCount() == 1 ) >+ || Koha::Libraries->search->count == 1 ) > { > my $DisplayLibraryFacets = C4::Context->preference('DisplayLibraryFacets'); > if ( $DisplayLibraryFacets eq 'both' >diff --git a/t/db_dependent/Branch.t b/t/db_dependent/Branch.t >index 2595704..791f545 100644 >--- a/t/db_dependent/Branch.t >+++ b/t/db_dependent/Branch.t >@@ -45,7 +45,7 @@ can_ok( > GetBranchesInCategory > ModBranchCategoryInfo > mybranch >- GetBranchesCount) >+ ) > ); > > >@@ -59,7 +59,7 @@ $dbh->do('DELETE FROM branchcategories'); > > # Start test > >-my $count = GetBranchesCount(); >+my $count = Koha::Libraries->search->count; > like( $count, '/^\d+$/', "the count is a number" ); > > #add 2 branches >@@ -111,10 +111,10 @@ is( ModBranch($b2), undef, 'the field add is missing' ); > > $b2->{add} = 1; > ModBranch($b2); >-is( GetBranchesCount(), $count + 2, "two branches added" ); >+is( Koha::Libraries->search->count, $count + 2, "two branches added" ); > > is( Koha::Libraries->find( $b2->{branchcode} )->delete, 1, "One row affected" ); >-is( GetBranchesCount(), $count + 1, "branch BRB deleted" ); >+is( Koha::Libraries->search->count, $count + 1, "branch BRB deleted" ); > > #Test GetBranchName > is( GetBranchName( $b1->{branchcode} ), >@@ -129,7 +129,7 @@ is_deeply( $branchdetail, $b1, 'branchdetail is right' ); > #Test Getbranches > my $branches = GetBranches(); > is( scalar( keys %$branches ), >- GetBranchesCount(), "GetBranches returns the right number of branches" ); >+ Koha::Libraries->search->count, "GetBranches returns the right number of branches" ); > > #Test ModBranch > >@@ -156,7 +156,7 @@ $b1 = { > }; > > ModBranch($b1); >-is( GetBranchesCount(), $count + 1, >+is( Koha::Libraries->search->count, $count + 1, > "A branch has been modified, no new branch added" ); > $branchdetail = GetBranchDetail( $b1->{branchcode} ); > $b1->{issuing} = undef; >@@ -211,7 +211,7 @@ is( Koha::LibraryCategories->search->count, $count_cat + 2, "Category CAT 2 dele > > $b2->{CAT1} = 1; > ModBranch($b2); >-is( GetBranchesCount(), $count + 2, 'BRB added' ); >+is( Koha::Libraries->search->count, $count + 2, 'BRB added' ); > > #Test GetBranchInfo > my $b1info = GetBranchInfo( $b1->{branchcode} ); >@@ -297,7 +297,7 @@ is_deeply( $brCat1, \@b, 'CAT1 has branch BRB and BRC' ); > > #Test GetBranchesLoop > my $loop = GetBranchesLoop; >-is( scalar(@$loop), GetBranchesCount(), 'There is the right number of branches' ); >+is( scalar(@$loop), Koha::Libraries->search->count, 'There is the right number of branches' ); > > # End transaction > $dbh->rollback; >-- >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 15295
:
45368
|
45369
|
45370
|
45371
|
45372
|
45373
|
45374
|
45375
|
45752
|
45754
|
45755
|
45756
|
45757
|
45760
|
45763
|
45764
|
45765
|
45924
|
45925
|
45926
|
45927
|
45928
|
45929
| 45930 |
45931
|
46684
|
46696