Bugzilla – Attachment 156959 Details for
Bug 33947
Move GetAllIssues to Koha
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 33947: Remove GetAllIssues
Bug-33947-Remove-GetAllIssues.patch (text/plain), 7.93 KB, created by
Nick Clemens (kidclamp)
on 2023-10-12 12:31:26 UTC
(
hide
)
Description:
Bug 33947: Remove GetAllIssues
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2023-10-12 12:31:26 UTC
Size:
7.93 KB
patch
obsolete
>From 411249a67d63702f914751710fd0254c2f1abeae Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 7 Jun 2023 16:56:05 +0200 >Subject: [PATCH] Bug 33947: Remove GetAllIssues > >No more occurrences of GetAllIssues, remove it! > >Test plan: > git grep is your friend > >Signed-off-by: David Nind <david@davidnind.com> >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >--- > C4/Members.pm | 55 ------------- > t/db_dependent/Members/GetAllIssues.t | 113 -------------------------- > 2 files changed, 168 deletions(-) > delete mode 100755 t/db_dependent/Members/GetAllIssues.t > >diff --git a/C4/Members.pm b/C4/Members.pm >index 919f6c3890..3c5a7dfb29 100644 >--- a/C4/Members.pm >+++ b/C4/Members.pm >@@ -42,8 +42,6 @@ BEGIN { > require Exporter; > @ISA = qw(Exporter); > @EXPORT_OK = qw( >- GetAllIssues >- > GetBorrowersToExpunge > > IssueSlip >@@ -231,59 +229,6 @@ sub patronflags { > return ( \%flags ); > } > >-=head2 GetAllIssues >- >- $issues = &GetAllIssues($borrowernumber, $sortkey, $limit); >- >-Looks up what the patron with the given borrowernumber has borrowed, >-and sorts the results. >- >-C<$sortkey> is the name of a field on which to sort the results. This >-should be the name of a field in the C<issues>, C<biblio>, >-C<biblioitems>, or C<items> table in the Koha database. >- >-C<$limit> is the maximum number of results to return. >- >-C<&GetAllIssues> an arrayref, C<$issues>, of hashrefs, the keys of which >-are the fields from the C<issues>, C<biblio>, C<biblioitems>, and >-C<items> tables of the Koha database. >- >-=cut >- >-#' >-sub GetAllIssues { >- my ( $borrowernumber, $order, $limit ) = @_; >- >- return unless $borrowernumber; >- $order = 'date_due desc' unless $order; >- >- my $dbh = C4::Context->dbh; >- my $query = >-'SELECT issues.*, items.*, biblio.*, biblioitems.*, issues.timestamp as issuestimestamp, issues.renewals_count AS renewals,items.renewals AS totalrenewals,items.timestamp AS itemstimestamp,borrowers.firstname,borrowers.surname >- FROM issues >- LEFT JOIN items on items.itemnumber=issues.itemnumber >- LEFT JOIN borrowers on borrowers.borrowernumber=issues.issuer_id >- LEFT JOIN biblio ON items.biblionumber=biblio.biblionumber >- LEFT JOIN biblioitems ON items.biblioitemnumber=biblioitems.biblioitemnumber >- WHERE issues.borrowernumber=? >- UNION ALL >- SELECT old_issues.*, items.*, biblio.*, biblioitems.*, old_issues.timestamp as issuestimestamp, old_issues.renewals_count AS renewals,items.renewals AS totalrenewals,items.timestamp AS itemstimestamp,borrowers.firstname,borrowers.surname >- FROM old_issues >- LEFT JOIN items on items.itemnumber=old_issues.itemnumber >- LEFT JOIN borrowers on borrowers.borrowernumber=old_issues.issuer_id >- LEFT JOIN biblio ON items.biblionumber=biblio.biblionumber >- LEFT JOIN biblioitems ON items.biblioitemnumber=biblioitems.biblioitemnumber >- WHERE old_issues.borrowernumber=? AND old_issues.itemnumber IS NOT NULL >- order by ' . $order; >- if ($limit) { >- $query .= " limit $limit"; >- } >- >- my $sth = $dbh->prepare($query); >- $sth->execute( $borrowernumber, $borrowernumber ); >- return $sth->fetchall_arrayref( {} ); >-} >- > =head2 GetBorrowersToExpunge > > $borrowers = &GetBorrowersToExpunge( >diff --git a/t/db_dependent/Members/GetAllIssues.t b/t/db_dependent/Members/GetAllIssues.t >deleted file mode 100755 >index 275faa509a..0000000000 >--- a/t/db_dependent/Members/GetAllIssues.t >+++ /dev/null >@@ -1,113 +0,0 @@ >-#!/usr/bin/perl >- >-# This file is part of Koha. >-# >-# Koha is free software; you can redistribute it and/or modify it >-# under the terms of the GNU General Public License as published by >-# the Free Software Foundation; either version 3 of the License, or >-# (at your option) any later version. >-# >-# Koha is distributed in the hope that it will be useful, but >-# WITHOUT ANY WARRANTY; without even the implied warranty of >-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >-# GNU General Public License for more details. >-# >-# You should have received a copy of the GNU General Public License >-# along with Koha; if not, see <http://www.gnu.org/licenses>. >- >-use Modern::Perl; >- >-use Test::More tests => 16; >-use Test::MockModule; >- >-use t::lib::TestBuilder; >- >-use C4::Circulation qw( AddIssue ); >-use C4::Biblio qw( AddBiblio ); >-use C4::Items; >-use C4::Members qw( GetAllIssues ); >-use Koha::Libraries; >-use Koha::Patrons; >-use MARC::Record; >- >-my $schema = Koha::Database->schema; >-my $dbh = C4::Context->dbh; >-$schema->storage->txn_begin; >- >-my $builder = t::lib::TestBuilder->new; >- >-$dbh->do(q|DELETE FROM issues|); >-$dbh->do(q|DELETE FROM borrowers|); >-$dbh->do(q|DELETE FROM items|); >-$dbh->do(q|DELETE FROM branches|); >-$dbh->do(q|DELETE FROM biblio|); >-$dbh->do(q|DELETE FROM categories|); >- >-my $branchcode = $builder->build( { source => 'Branch' } )->{branchcode}; >-my $categorycode = $builder->build( { source => 'Category' } )->{categorycode}; >-my $itemtype = $builder->build( { source => 'Itemtype' } )->{itemtype}; >- >-my %item_infos = ( >- homebranch => $branchcode, >- holdingbranch => $branchcode, >- itype => $itemtype >-); >- >-my ($biblionumber1) = AddBiblio( MARC::Record->new, '' ); >- >-# FIXME These tests will fail if the barcode exists in DB >-my $itemnumber1 = $builder->build_sample_item({ biblionumber => $biblionumber1, barcode => '0101', %item_infos })->itemnumber; >-my $itemnumber2 = $builder->build_sample_item({ biblionumber => $biblionumber1, barcode => '0102', %item_infos })->itemnumber; >- >-my ($biblionumber2) = AddBiblio( MARC::Record->new, '' ); >-my $itemnumber3 = $builder->build_sample_item({ biblionumber => $biblionumber2, barcode => '0202', %item_infos })->itemnumber; >- >-my $borrowernumber1 = >- Koha::Patron->new({ categorycode => $categorycode, branchcode => $branchcode })->store->borrowernumber; >-my $borrowernumber2 = >- Koha::Patron->new({ categorycode => $categorycode, branchcode => $branchcode })->store->borrowernumber; >-my $borrower1 = Koha::Patrons->find( $borrowernumber1 ); >-my $borrower2 = Koha::Patrons->find( $borrowernumber2 ); >- >-my $module = Test::MockModule->new('C4::Context'); >-$module->mock( 'userenv', sub { { branch => $branchcode } } ); >- >-my $issues = C4::Members::GetAllIssues(); >-is( $issues, undef, 'GetAllIssues without borrower number returns undef' ); >- >-$issues = C4::Members::GetAllIssues($borrowernumber1); >-is( @$issues, 0, 'GetAllIssues returns the correct number of elements' ); >-$issues = C4::Members::GetAllIssues($borrowernumber2); >-is( @$issues, 0, 'GetAllIssues returns the correct number of elements' ); >- >-AddIssue( $borrower1, '0101' ); >-$issues = C4::Members::GetAllIssues($borrowernumber1); >-my $issues_with_order = >- C4::Members::GetAllIssues( $borrowernumber1, 'date_due desc' ); >-is_deeply( $issues, $issues_with_order, >-'The value by default for the argument order in GellAllIssues is date_due_desc' >-); >-is( @$issues, 1, 'GetAllIssues returns the correct number of elements' ); >-is( $issues->[0]->{itemnumber}, $itemnumber1, '' ); >-$issues = C4::Members::GetAllIssues($borrowernumber2); >-is( @$issues, 0, 'GetAllIssues returns the correct number of elements' ); >- >-AddIssue( $borrower1, '0102' ); >-$issues = C4::Members::GetAllIssues($borrowernumber1); >-is( @$issues, 2, 'GetAllIssues returns the correct number of elements' ); >-is( $issues->[0]->{itemnumber}, $itemnumber1, '' ); >-is( $issues->[1]->{itemnumber}, $itemnumber2, '' ); >-$issues = C4::Members::GetAllIssues($borrowernumber2); >-is( @$issues, 0, 'GetAllIssues returns the correct number of elements' ); >- >-AddIssue( $borrower2, '0202' ); >-$issues = C4::Members::GetAllIssues($borrowernumber1); >-is( @$issues, 2, 'GetAllIssues returns the correct number of elements' ); >-is( $issues->[0]->{itemnumber}, $itemnumber1, '' ); >-is( $issues->[1]->{itemnumber}, $itemnumber2, '' ); >-$issues = C4::Members::GetAllIssues($borrowernumber2); >-is( @$issues, 1, 'GetAllIssues returns the correct number of elements' ); >-is( $issues->[0]->{itemnumber}, $itemnumber3, '' ); >- >-$schema->storage->txn_begin; >- >-- >2.30.2
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 33947
:
152156
|
152195
|
156444
|
156445
| 156959