Bugzilla – Attachment 181422 Details for
Bug 39727
Remove DelSuggestionsOlderThan from C4/Suggestions.pm
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 39727: Remove DelSuggestionsOlderThan from C4/Suggestions.pm
Bug-39727-Remove-DelSuggestionsOlderThan-from-C4Su.patch (text/plain), 4.87 KB, created by
Baptiste Wojtkowski (bwoj)
on 2025-04-24 09:49:09 UTC
(
hide
)
Description:
Bug 39727: Remove DelSuggestionsOlderThan from C4/Suggestions.pm
Filename:
MIME Type:
Creator:
Baptiste Wojtkowski (bwoj)
Created:
2025-04-24 09:49:09 UTC
Size:
4.87 KB
patch
obsolete
>From dd162842ef8c0511dede96a6974f352285fecccb Mon Sep 17 00:00:00 2001 >From: Baptiste Wojtkowski <baptiste.wojtkowski@biblibre.com> >Date: Tue, 8 Apr 2025 16:05:14 +0200 >Subject: [PATCH] Bug 39727: Remove DelSuggestionsOlderThan from > C4/Suggestions.pm > >To test: >Test the cronjob purge_suggestions.pl >--- > C4/Suggestions.pm | 23 ---------------- > misc/cronjobs/purge_suggestions.pl | 7 ++++- > t/db_dependent/Suggestions.t | 42 ++---------------------------- > 3 files changed, 8 insertions(+), 64 deletions(-) > >diff --git a/C4/Suggestions.pm b/C4/Suggestions.pm >index d22ca13a..e7f9abfc 100644 >--- a/C4/Suggestions.pm >+++ b/C4/Suggestions.pm >@@ -35,7 +35,6 @@ our @EXPORT = qw( > DelSuggestion > ModStatus > ModSuggestion >- DelSuggestionsOlderThan > GetUnprocessedSuggestions > MarcRecordFromNewSuggestion > ); >@@ -174,28 +173,6 @@ sub DelSuggestion { > } > } > >-=head2 DelSuggestionsOlderThan >- &DelSuggestionsOlderThan($days) >- >- Delete all suggestions older than TODAY-$days , that have be accepted or rejected. >- We do now allow a negative number. If you want to delete all suggestions, just use Koha::Suggestions->delete or so. >- >-=cut >- >-sub DelSuggestionsOlderThan { >- my ($days) = @_; >- return unless $days && $days > 0; >- my $dbh = C4::Context->dbh; >- my $sth = $dbh->prepare( >- q{ >- DELETE FROM suggestions >- WHERE STATUS<>'ASKED' >- AND manageddate < ADDDATE(NOW(), ?) >- } >- ); >- $sth->execute("-$days"); >-} >- > sub GetUnprocessedSuggestions { > my ($number_of_days_since_the_last_modification) = @_; > >diff --git a/misc/cronjobs/purge_suggestions.pl b/misc/cronjobs/purge_suggestions.pl >index c57145db..00794c46 100755 >--- a/misc/cronjobs/purge_suggestions.pl >+++ b/misc/cronjobs/purge_suggestions.pl >@@ -63,7 +63,12 @@ if ( !$confirm || $help || !defined($days) ) { > print $usage; > } elsif ( $days and $days > 0 ) { > print "Purging suggestions older than $days days\n" if $verbose; >- DelSuggestionsOlderThan($days); >+ Koha::Suggestions->search( { STATUS => { '!=' => 'ASKED' } } )->filter_by_last_update( >+ { >+ days => $days, >+ timestamp_column_name => 'manageddate', >+ } >+ )->delete; > } else { > warn "This script requires a positive number of days. Aborted.\n"; > } >diff --git a/t/db_dependent/Suggestions.t b/t/db_dependent/Suggestions.t >index 10b9123a..79be3836 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 => 52; >+use Test::More tests => 51; > use Test::Warn; > > use t::lib::Mocks; >@@ -38,7 +38,7 @@ use Koha::Suggestions; > BEGIN { > use_ok( > 'C4::Suggestions', >- qw( ModSuggestion DelSuggestion MarcRecordFromNewSuggestion GetUnprocessedSuggestions DelSuggestionsOlderThan ) >+ qw( ModSuggestion DelSuggestion MarcRecordFromNewSuggestion GetUnprocessedSuggestions ) > ); > } > >@@ -429,44 +429,6 @@ subtest 'GetUnprocessedSuggestions' => sub { > ); > }; > >-subtest 'DelSuggestionsOlderThan' => sub { >- plan tests => 6; >- >- Koha::Suggestions->delete; >- >- # Add four suggestions; note that STATUS needs uppercase (FIXME) >- my $d1 = output_pref( { dt => dt_from_string->add( days => -2 ), dateformat => 'sql' } ); >- my $d2 = output_pref( { dt => dt_from_string->add( days => -4 ), dateformat => 'sql' } ); >- my $sugg01 = >- $builder->build( { source => 'Suggestion', value => { manageddate => $d1, date => $d2, STATUS => 'ASKED' } } ); >- my $sugg02 = $builder->build( >- { source => 'Suggestion', value => { manageddate => $d1, date => $d2, STATUS => 'CHECKED' } } ); >- my $sugg03 = >- $builder->build( { source => 'Suggestion', value => { manageddate => $d2, date => $d2, STATUS => 'ASKED' } } ); >- my $sugg04 = $builder->build( >- { source => 'Suggestion', value => { manageddate => $d2, date => $d2, STATUS => 'ACCEPTED' } } ); >- >- # Test no parameter: should do nothing >- C4::Suggestions::DelSuggestionsOlderThan(); >- is( Koha::Suggestions->count, 4, 'No suggestions deleted' ); >- >- # Test zero: should do nothing too >- C4::Suggestions::DelSuggestionsOlderThan(0); >- is( Koha::Suggestions->count, 4, 'No suggestions deleted again' ); >- >- # Test negative value >- C4::Suggestions::DelSuggestionsOlderThan(-1); >- is( Koha::Suggestions->count, 4, 'No suggestions deleted for -1' ); >- >- # Test positive values >- C4::Suggestions::DelSuggestionsOlderThan(5); >- is( Koha::Suggestions->count, 4, 'No suggestions>5d deleted' ); >- C4::Suggestions::DelSuggestionsOlderThan(3); >- is( Koha::Suggestions->count, 3, '1 suggestions>3d deleted' ); >- C4::Suggestions::DelSuggestionsOlderThan(1); >- is( Koha::Suggestions->count, 2, '1 suggestions>1d deleted' ); >-}; >- > subtest 'EmailPurchaseSuggestions' => sub { > plan tests => 11; > >-- >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 39727
:
181413
| 181422