Bugzilla – Attachment 70361 Details for
Bug 19935
Move C4::Members::GetPendingIssues to the Koha namespace
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19935: Replace GetPendingIssues - Remove the residue
Bug-19935-Replace-GetPendingIssues---Remove-the-re.patch (text/plain), 9.54 KB, created by
Jonathan Druart
on 2018-01-09 14:31:48 UTC
(
hide
)
Description:
Bug 19935: Replace GetPendingIssues - Remove the residue
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2018-01-09 14:31:48 UTC
Size:
9.54 KB
patch
obsolete
>From 7cf0f7f6f0c6d2f59ca4018eed6d7258239f178f Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 8 Jan 2018 12:32:55 -0300 >Subject: [PATCH] Bug 19935: Replace GetPendingIssues - Remove the residue > >Here we are, no more occurrences of GetPendingIssues, we can remove the >tests and subroutine \o/ >--- > C4/Members.pm | 89 +------------------- > t/db_dependent/Members/GetPendingIssues.t | 130 ------------------------------ > 2 files changed, 1 insertion(+), 218 deletions(-) > delete mode 100644 t/db_dependent/Members/GetPendingIssues.t > >diff --git a/C4/Members.pm b/C4/Members.pm >index c56f142ead..17cd64736c 100644 >--- a/C4/Members.pm >+++ b/C4/Members.pm >@@ -62,7 +62,6 @@ BEGIN { > #Get data > push @EXPORT, qw( > >- &GetPendingIssues > &GetAllIssues > > &GetBorrowersToExpunge >@@ -597,92 +596,6 @@ sub fixup_cardnumber { > return $cardnumber; # just here as a fallback/reminder > } > >-=head2 GetPendingIssues >- >- my $issues = &GetPendingIssues(@borrowernumber); >- >-Looks up what the patron with the given borrowernumber has borrowed. >- >-C<&GetPendingIssues> returns a >-reference-to-array where each element is a reference-to-hash; the >-keys are the fields from the C<issues>, C<biblio>, and C<items> tables. >-The keys include C<biblioitems> fields. >- >-=cut >- >-sub GetPendingIssues { >- my @borrowernumbers = @_; >- >- unless (@borrowernumbers ) { # return a ref_to_array >- return \@borrowernumbers; # to not cause surprise to caller >- } >- >- # Borrowers part of the query >- my $bquery = ''; >- for (my $i = 0; $i < @borrowernumbers; $i++) { >- $bquery .= ' issues.borrowernumber = ?'; >- if ($i < $#borrowernumbers ) { >- $bquery .= ' OR'; >- } >- } >- >- # FIXME: namespace collision: each table has "timestamp" fields. Which one is "timestamp" ? >- # FIXME: circ/ciculation.pl tries to sort by timestamp! >- # FIXME: namespace collision: other collisions possible. >- # FIXME: most of this data isn't really being used by callers. >- my $query = >- "SELECT issues.*, >- items.*, >- biblio.*, >- biblioitems.volume, >- biblioitems.number, >- biblioitems.itemtype, >- biblioitems.isbn, >- biblioitems.issn, >- biblioitems.publicationyear, >- biblioitems.publishercode, >- biblioitems.volumedate, >- biblioitems.volumedesc, >- biblioitems.lccn, >- biblioitems.url, >- borrowers.firstname, >- borrowers.surname, >- borrowers.cardnumber, >- issues.timestamp AS timestamp, >- issues.renewals AS renewals, >- issues.borrowernumber AS borrowernumber, >- items.renewals AS totalrenewals >- FROM issues >- LEFT JOIN items ON items.itemnumber = issues.itemnumber >- LEFT JOIN biblio ON items.biblionumber = biblio.biblionumber >- LEFT JOIN biblioitems ON items.biblioitemnumber = biblioitems.biblioitemnumber >- LEFT JOIN borrowers ON issues.borrowernumber = borrowers.borrowernumber >- WHERE >- $bquery >- ORDER BY issues.issuedate" >- ; >- >- my $sth = C4::Context->dbh->prepare($query); >- $sth->execute(@borrowernumbers); >- my $data = $sth->fetchall_arrayref({}); >- my $today = dt_from_string; >- foreach (@{$data}) { >- if ($_->{issuedate}) { >- $_->{issuedate} = dt_from_string($_->{issuedate}, 'sql'); >- } >- $_->{date_due_sql} = $_->{date_due}; >- # FIXME no need to have this value >- $_->{date_due} or next; >- $_->{date_due_sql} = $_->{date_due}; >- # FIXME no need to have this value >- $_->{date_due} = dt_from_string($_->{date_due}, 'sql'); >- if ( DateTime->compare($_->{date_due}, $today) == -1 ) { >- $_->{overdue} = 1; >- } >- } >- return $data; >-} >- > =head2 GetAllIssues > > $issues = &GetAllIssues($borrowernumber, $sortkey, $limit); >@@ -931,7 +844,7 @@ sub GetBorrowersToExpunge { > <<issues.*>> > </checkedout> > >- NOTE: Not all table fields are available, pleasee see GetPendingIssues for a list of available fields. >+ NOTE: Fields from tables issues, items, biblio and biblioitems are available > > =cut > >diff --git a/t/db_dependent/Members/GetPendingIssues.t b/t/db_dependent/Members/GetPendingIssues.t >deleted file mode 100644 >index 56e06965b0..0000000000 >--- a/t/db_dependent/Members/GetPendingIssues.t >+++ /dev/null >@@ -1,130 +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 => 20; >-use Test::MockModule; >- >-use t::lib::TestBuilder; >- >-use C4::Biblio; >-use C4::Items; >-use C4::Members; >-use C4::Circulation; >-use Koha::Library; >-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, '' ); >-my $itemnumber1 = >- AddItem( { barcode => '0101', %item_infos }, $biblionumber1 ); >-my $itemnumber2 = >- AddItem( { barcode => '0102', %item_infos }, $biblionumber1 ); >- >-my ($biblionumber2) = AddBiblio( MARC::Record->new, '' ); >-my $itemnumber3 = >- AddItem( { barcode => '0203', %item_infos }, $biblionumber2 ); >- >-my $borrowernumber1 = >- AddMember( categorycode => $categorycode, branchcode => $branchcode ); >-my $borrowernumber2 = >- AddMember( categorycode => $categorycode, branchcode => $branchcode ); >-my $borrower1 = Koha::Patrons->find( $borrowernumber1 )->unblessed; >-my $borrower2 = Koha::Patrons->find( $borrowernumber2 )->unblessed; >- >-my $module = new Test::MockModule('C4::Context'); >-$module->mock( 'userenv', sub { { branch => $branchcode } } ); >- >-my $issues = >- C4::Members::GetPendingIssues( $borrowernumber1, $borrowernumber2 ); >-is( @$issues, 0, 'GetPendingIssues returns the correct number of elements' ); >- >-AddIssue( $borrower1, '0101' ); >-$issues = C4::Members::GetPendingIssues($borrowernumber1); >-is( @$issues, 1, 'GetPendingIssues returns the correct number of elements' ); >-is( $issues->[0]->{itemnumber}, >- $itemnumber1, 'GetPendingIssues returns the itemnumber correctly' ); >-my $issues_bis = >- C4::Members::GetPendingIssues( $borrowernumber1, $borrowernumber2 ); >-is_deeply( $issues, $issues_bis, 'GetPendingIssues functions correctly' ); >-$issues = C4::Members::GetPendingIssues($borrowernumber2); >-is( @$issues, 0, 'GetPendingIssues returns the correct number of elements' ); >- >-AddIssue( $borrower1, '0102' ); >-$issues = C4::Members::GetPendingIssues($borrowernumber1); >-is( @$issues, 2, 'GetPendingIssues returns the correct number of elements' ); >-is( $issues->[0]->{itemnumber}, >- $itemnumber1, 'GetPendingIssues returns the itemnumber correctly' ); >-is( $issues->[1]->{itemnumber}, >- $itemnumber2, 'GetPendingIssues returns the itemnumber correctly' ); >-$issues_bis = >- C4::Members::GetPendingIssues( $borrowernumber1, $borrowernumber2 ); >-is_deeply( $issues, $issues_bis, 'GetPendingIssues functions correctly' ); >-$issues = C4::Members::GetPendingIssues($borrowernumber2); >-is( @$issues, 0, 'GetPendingIssues returns the correct number of elements' ); >- >-AddIssue( $borrower2, '0203' ); >-$issues = C4::Members::GetPendingIssues($borrowernumber2); >-is( @$issues, 1, 'GetAllIssues returns the correct number of elements' ); >-is( $issues->[0]->{itemnumber}, >- $itemnumber3, 'GetPendingIssues returns the itemnumber correctly' ); >-$issues = C4::Members::GetPendingIssues($borrowernumber1); >-is( @$issues, 2, 'GetPendingIssues returns the correct number of elements' ); >-is( $issues->[0]->{itemnumber}, >- $itemnumber1, 'GetPendingIssues returns the itemnumber correctly' ); >-is( $issues->[1]->{itemnumber}, >- $itemnumber2, 'GetPendingIssues returns the itemnumber correctly' ); >-$issues = C4::Members::GetPendingIssues( $borrowernumber1, $borrowernumber2 ); >-is( @$issues, 3, 'GetPendingIssues returns the correct number of elements' ); >-is( $issues->[0]->{itemnumber}, >- $itemnumber1, 'GetPendingIssues returns the itemnumber correctly' ); >-is( $issues->[1]->{itemnumber}, >- $itemnumber2, 'GetPendingIssues returns the itemnumber correctly' ); >-is( $issues->[2]->{itemnumber}, >- $itemnumber3, 'GetPendingIssues returns the itemnumber correctly' ); >- >-$issues = C4::Members::GetPendingIssues(); >-is( @$issues, 0, >- 'GetPendingIssues without borrower numbers returns an empty array' ); >- >-$schema->storage->txn_begin; >- >-- >2.11.0
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 19935
:
70351
|
70352
|
70353
|
70354
|
70355
|
70356
|
70357
|
70358
|
70359
|
70360
|
70361
|
71807
|
71808
|
71809
|
71810
|
71811
|
71812
|
71813
|
72752
|
72753
|
72754
|
72755
|
72756
|
72757
|
72758
|
72759
|
72760
|
72761
|
72762
|
73557
|
73558
|
73559
|
73560
|
73561
|
73562
|
73563
|
73564
|
73565
|
73566
|
73567
|
73568
|
73569
|
73570
|
73571
|
73572
|
73573
|
73574
|
73575
|
73576
|
73577
|
73578
|
73579
|
73580
|
73581
|
73582