Bugzilla – Attachment 193978 Details for
Bug 39728
Remove GetUnprocessedSuggestions from C4/Suggestions.pm
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 39728: Remove GetUnprocessedSuggestions from C4/Suggestions.pm
Bug-39728-Remove-GetUnprocessedSuggestions-from-C4.patch (text/plain), 6.14 KB, created by
Baptiste Wojtkowski (bwoj)
on 2026-02-26 10:20:17 UTC
(
hide
)
Description:
Bug 39728: Remove GetUnprocessedSuggestions from C4/Suggestions.pm
Filename:
MIME Type:
Creator:
Baptiste Wojtkowski (bwoj)
Created:
2026-02-26 10:20:17 UTC
Size:
6.14 KB
patch
obsolete
>From 74d7e9c6743e5f92238487903bcdceec8045525a Mon Sep 17 00:00:00 2001 >From: Baptiste Wojtkowski <baptiste.wojtkowski@biblibre.com> >Date: Thu, 26 Feb 2026 10:18:35 +0000 >Subject: [PATCH] Bug 39728: Remove GetUnprocessedSuggestions from > C4/Suggestions.pm > >--- > C4/Suggestions.pm | 26 -------- > .../notice_unprocessed_suggestions.pl | 12 +++- > t/db_dependent/Suggestions.t | 64 +------------------ > 3 files changed, 13 insertions(+), 89 deletions(-) > >diff --git a/C4/Suggestions.pm b/C4/Suggestions.pm >index 0d214acd906..946fa23b8a8 100644 >--- a/C4/Suggestions.pm >+++ b/C4/Suggestions.pm >@@ -27,7 +27,6 @@ BEGIN { > GetSuggestion > ModStatus > ModSuggestion >- GetUnprocessedSuggestions > MarcRecordFromNewSuggestion > ); > } >@@ -187,31 +186,6 @@ sub DelSuggestion { > } > } > >-=head2 GetUnprocessedSuggestions >- >-Missing POD for GetUnprocessedSuggestions. >- >-=cut >- >-sub GetUnprocessedSuggestions { >- my ($number_of_days_since_the_last_modification) = @_; >- >- $number_of_days_since_the_last_modification ||= 0; >- >- my $dbh = C4::Context->dbh; >- >- my $s = $dbh->selectall_arrayref( >- q| >- SELECT * >- FROM suggestions >- WHERE STATUS = 'ASKED' >- AND budgetid IS NOT NULL >- AND CAST(NOW() AS DATE) - INTERVAL ? DAY = CAST(suggesteddate AS DATE) >- |, { Slice => {} }, $number_of_days_since_the_last_modification >- ); >- return $s; >-} >- > =head2 MarcRecordFromNewSuggestion > > $record = MarcRecordFromNewSuggestion ( $suggestion ) >diff --git a/misc/cronjobs/notice_unprocessed_suggestions.pl b/misc/cronjobs/notice_unprocessed_suggestions.pl >index f2b201fa039..36c55c1a08b 100755 >--- a/misc/cronjobs/notice_unprocessed_suggestions.pl >+++ b/misc/cronjobs/notice_unprocessed_suggestions.pl >@@ -37,7 +37,17 @@ unless ($confirm) { > for my $number_of_days (@days) { > say "Searching suggestions suggested $number_of_days days ago" if $verbose; > >- my $suggestions = C4::Suggestions::GetUnprocessedSuggestions($number_of_days); >+ my $suggestions = Koha::Suggestions->search( >+ { >+ STATUS => 'ASKED', >+ budgetid => { '!=' => undef } >+ } >+ )->filter_by_last_update( >+ { >+ exact_days => $number_of_days, >+ timestamp_column_name => 'suggesteddate', >+ } >+ )->as_list; > > say "No suggestion found" if $verbose and not @$suggestions; > >diff --git a/t/db_dependent/Suggestions.t b/t/db_dependent/Suggestions.t >index 36c579f3b2b..a0012a77c4c 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 => 49; >+use Test::More tests => 48; > use Test::Warn; > > use t::lib::Mocks; >@@ -38,7 +38,7 @@ use Koha::Suggestions; > BEGIN { > use_ok( > 'C4::Suggestions', >- qw( ModSuggestion DelSuggestion MarcRecordFromNewSuggestion GetUnprocessedSuggestions ) >+ qw( ModSuggestion DelSuggestion MarcRecordFromNewSuggestion ) > ); > } > >@@ -363,66 +363,6 @@ is( > "Record from suggestion author should be 'Catherine'" > ); > >-subtest 'GetUnprocessedSuggestions' => sub { >- plan tests => 11; >- $dbh->do(q|DELETE FROM suggestions|); >- my $my_suggestionid = Koha::Suggestion->new($my_suggestion)->store->id; >- my $unprocessed_suggestions = C4::Suggestions::GetUnprocessedSuggestions; >- is( >- scalar(@$unprocessed_suggestions), 0, >- 'GetUnprocessedSuggestions should return 0 if a suggestion has been processed but not linked to a fund' >- ); >- my $status = ModSuggestion($mod_suggestion1); >- my $suggestion = Koha::Suggestions->find($my_suggestionid); >- is( $suggestion->budgetid, undef, 'ModSuggestion should set budgetid to NULL if not given' ); >- ModSuggestion( { suggestionid => $my_suggestionid, budgetid => $budget_id } ); >- $suggestion = Koha::Suggestions->find($my_suggestionid); >- is( $suggestion->budgetid, $budget_id, 'ModSuggestion should modify budgetid if given' ); >- >- $unprocessed_suggestions = C4::Suggestions::GetUnprocessedSuggestions; >- is( >- scalar(@$unprocessed_suggestions), 1, >- 'GetUnprocessedSuggestions should return the suggestion if the suggestion is linked to a fund and has not been processed yet' >- ); >- >- warning_is { ModSuggestion( { suggestionid => $my_suggestionid, STATUS => 'REJECTED' } ) } >- 'No suggestions REJECTED letter transported by email', >- 'Warning raised if no REJECTED letter by email'; >- $unprocessed_suggestions = C4::Suggestions::GetUnprocessedSuggestions; >- is( >- scalar(@$unprocessed_suggestions), 0, >- 'GetUnprocessedSuggestions should return the suggestion if the suggestion is linked to a fund and has not been processed yet' >- ); >- >- warning_is { >- ModSuggestion( >- { >- suggestionid => $my_suggestionid, STATUS => 'ASKED', >- suggesteddate => dt_from_string->add_duration( DateTime::Duration->new( days => -4 ) ) >- } >- ); >- } >- 'No suggestions ASKED letter transported by email', >- 'Warning raised if no ASKED letter by email'; >- $unprocessed_suggestions = C4::Suggestions::GetUnprocessedSuggestions; >- is( scalar(@$unprocessed_suggestions), 0, 'GetUnprocessedSuggestions should use 0 as default value for days' ); >- $unprocessed_suggestions = C4::Suggestions::GetUnprocessedSuggestions(4); >- is( >- scalar(@$unprocessed_suggestions), 1, >- 'GetUnprocessedSuggestions should return the suggestion suggested 4 days ago' >- ); >- $unprocessed_suggestions = C4::Suggestions::GetUnprocessedSuggestions(3); >- is( >- scalar(@$unprocessed_suggestions), 0, >- 'GetUnprocessedSuggestions should not return the suggestion, it has not been suggested 3 days ago' >- ); >- $unprocessed_suggestions = C4::Suggestions::GetUnprocessedSuggestions(5); >- is( >- scalar(@$unprocessed_suggestions), 0, >- 'GetUnprocessedSuggestions should not return the suggestion, it has not been suggested 5 days ago' >- ); >-}; >- > subtest 'EmailPurchaseSuggestions' => sub { > plan tests => 11; > >-- >2.43.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 39728
:
181410
|
181414
|
181423
| 193978