Bugzilla – Attachment 181406 Details for
Bug 39725
Remove GetSuggestionByStatus from C4/Suggestions.pm
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 39725: Remove GetSuggestionByStatus from C4/Suggestions.pm
Bug-39725-Remove-GetSuggestionByStatus-from-C4Sugg.patch (text/plain), 6.97 KB, created by
Baptiste Wojtkowski (bwoj)
on 2025-04-24 08:58:42 UTC
(
hide
)
Description:
Bug 39725: Remove GetSuggestionByStatus from C4/Suggestions.pm
Filename:
MIME Type:
Creator:
Baptiste Wojtkowski (bwoj)
Created:
2025-04-24 08:58:42 UTC
Size:
6.97 KB
patch
obsolete
>From c61ecf6066751e26786ccfa86a8f0793f2a7694e Mon Sep 17 00:00:00 2001 >From: Baptiste Wojtkowski <baptiste.wojtkowski@biblibre.com> >Date: Tue, 8 Apr 2025 15:12:28 +0200 >Subject: [PATCH] Bug 39725: Remove GetSuggestionByStatus from > C4/Suggestions.pm > >Note: not used in koha >--- > C4/Suggestions.pm | 60 ------------------------------------ > t/db_dependent/Suggestions.t | 51 +++--------------------------- > 2 files changed, 5 insertions(+), 106 deletions(-) > >diff --git a/C4/Suggestions.pm b/C4/Suggestions.pm >index 4ac59001..6d444d3b 100644 >--- a/C4/Suggestions.pm >+++ b/C4/Suggestions.pm >@@ -34,7 +34,6 @@ use base qw(Exporter); > our @EXPORT = qw( > ConnectSuggestionAndBiblio > DelSuggestion >- GetSuggestionByStatus > ModStatus > ModSuggestion > DelSuggestionsOlderThan >@@ -67,65 +66,6 @@ Suggestions done by other borrowers can be seen when not "AVAILABLE" > > =head1 FUNCTIONS > >-=head2 GetSuggestionByStatus >- >-$aqorders = &GetSuggestionByStatus($status,[$branchcode]) >- >-Get a suggestion from it's status >- >-return : >-all the suggestion with C<$status> >- >-=cut >- >-sub GetSuggestionByStatus { >- my $status = shift; >- my $branchcode = shift; >- my $dbh = C4::Context->dbh; >- my @sql_params = ($status); >- my $query = q{ >- SELECT suggestions.*, >- U1.surname AS surnamesuggestedby, >- U1.firstname AS firstnamesuggestedby, >- U1.branchcode AS branchcodesuggestedby, >- B1.branchname AS branchnamesuggestedby, >- U1.borrowernumber AS borrnumsuggestedby, >- U1.categorycode AS categorycodesuggestedby, >- C1.description AS categorydescriptionsuggestedby, >- U2.surname AS surnamemanagedby, >- U2.firstname AS firstnamemanagedby, >- U2.borrowernumber AS borrnummanagedby >- FROM suggestions >- LEFT JOIN borrowers AS U1 ON suggestedby=U1.borrowernumber >- LEFT JOIN borrowers AS U2 ON managedby=U2.borrowernumber >- LEFT JOIN categories AS C1 ON C1.categorycode=U1.categorycode >- LEFT JOIN branches AS B1 on B1.branchcode=U1.branchcode >- WHERE status = ? >- ORDER BY suggestionid >- }; >- >- # filter on branch >- if ( C4::Context->preference("IndependentBranches") || $branchcode ) { >- my $userenv = C4::Context->userenv; >- if ($userenv) { >- unless ( C4::Context->IsSuperLibrarian() ) { >- push @sql_params, $userenv->{branch}; >- $query .= q{ AND (U1.branchcode = ? OR U1.branchcode ='') }; >- } >- } >- if ($branchcode) { >- push @sql_params, $branchcode; >- $query .= q{ AND (U1.branchcode = ? OR U1.branchcode ='') }; >- } >- } >- >- my $sth = $dbh->prepare($query); >- $sth->execute(@sql_params); >- my $results; >- $results = $sth->fetchall_arrayref( {} ); >- return $results; >-} >- > =head2 ModSuggestion > > &ModSuggestion($suggestion) >diff --git a/t/db_dependent/Suggestions.t b/t/db_dependent/Suggestions.t >index 3d6d5b71..33b4ffb3 100755 >--- a/t/db_dependent/Suggestions.t >+++ b/t/db_dependent/Suggestions.t >@@ -19,7 +19,7 @@ use Modern::Perl; > > use DateTime::Duration; > use Test::NoWarnings; >-use Test::More tests => 69; >+use Test::More tests => 55; > use Test::Warn; > > use t::lib::Mocks; >@@ -38,7 +38,7 @@ use Koha::Suggestions; > BEGIN { > use_ok( > 'C4::Suggestions', >- qw( ModSuggestion GetSuggestionByStatus ConnectSuggestionAndBiblio DelSuggestion MarcRecordFromNewSuggestion GetUnprocessedSuggestions DelSuggestionsOlderThan ) >+ qw( ModSuggestion ConnectSuggestionAndBiblio DelSuggestion MarcRecordFromNewSuggestion GetUnprocessedSuggestions DelSuggestionsOlderThan ) > ); > } > >@@ -310,47 +310,6 @@ $messages = C4::Letters::GetQueuedMessages( { borrowernumber => $borrowernumber2 > > is( scalar(@$messages), 1, 'No new letter should have been generated if the update raised an error' ); > >-my $suggestions = GetSuggestionByStatus(); >-is( @$suggestions, 0, 'GetSuggestionByStatus without the status returns an empty array' ); >-$suggestions = GetSuggestionByStatus('CHECKED'); >-is( @$suggestions, 2, 'GetSuggestionByStatus returns the correct number of suggestions' ); >-is( $suggestions->[0]->{suggestionid}, $my_suggestionid, 'GetSuggestionByStatus returns the suggestion id correctly' ); >-is( $suggestions->[0]->{title}, $mod_suggestion1->{title}, 'GetSuggestionByStatus returns the title correctly' ); >-is( $suggestions->[0]->{author}, $mod_suggestion1->{author}, 'GetSuggestionByStatus returns the author correctly' ); >-is( >- $suggestions->[0]->{publishercode}, $mod_suggestion1->{publishercode}, >- 'GetSuggestionByStatus returns the publisher code correctly' >-); >-is( >- $suggestions->[0]->{suggestedby}, $my_suggestion->{suggestedby}, >- 'GetSuggestionByStatus returns the borrower number correctly' >-); >-is( >- $suggestions->[0]->{biblionumber}, $my_suggestion->{biblionumber}, >- 'GetSuggestionByStatus returns the biblio number correctly' >-); >-is( $suggestions->[0]->{STATUS}, $mod_suggestion3->{STATUS}, 'GetSuggestionByStatus returns the status correctly' ); >-is( >- $suggestions->[0]->{surnamesuggestedby}, $member->{surname}, >- 'GetSuggestionByStatus returns the surname correctly' >-); >-is( >- $suggestions->[0]->{firstnamesuggestedby}, $member->{firstname}, >- 'GetSuggestionByStatus returns the firstname correctly' >-); >-is( >- $suggestions->[0]->{branchcodesuggestedby}, $member->{branchcode}, >- 'GetSuggestionByStatus returns the branch code correctly' >-); >-is( >- $suggestions->[0]->{borrnumsuggestedby}, $my_suggestion->{suggestedby}, >- 'GetSuggestionByStatus returns the borrower number correctly' >-); >-is( >- $suggestions->[0]->{categorycodesuggestedby}, $member->{categorycode}, >- 'GetSuggestionByStatus returns the category code correctly' >-); >- > is( ConnectSuggestionAndBiblio(), '0E0', 'ConnectSuggestionAndBiblio without arguments returns 0E0' ); > my $biblio_2 = $builder->build_object( { class => 'Koha::Biblios' } ); > my $connect_suggestion_and_biblio = ConnectSuggestionAndBiblio( $my_suggestionid, $biblio_2->biblionumber ); >@@ -378,9 +337,9 @@ is( > $suggestion = DelSuggestion( $borrowernumber, $my_suggestionid ); > is( $suggestion, 1, 'DelSuggestion deletes one suggestion' ); > >-$suggestions = GetSuggestionByStatus('CHECKED'); >-is( @$suggestions, 2, 'DelSuggestion deletes one suggestion' ); >-is( $suggestions->[1]->{title}, $del_suggestion->{title}, 'DelSuggestion deletes the correct suggestion' ); >+my $suggestions = Koha::Suggestions->search( { STATUS => 'CHECKED' } )->as_list; >+is( @$suggestions, 2, 'DelSuggestion deletes one suggestion' ); >+is( $suggestions->[1]->unblessed()->{title}, $del_suggestion->{title}, 'DelSuggestion deletes the correct suggestion' ); > > # Test budgetid fk > $my_suggestion->{budgetid} = ''; # If budgetid == '', NULL should be set in DB >-- >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 39725
: 181406