Bugzilla – Attachment 101541 Details for
Bug 24541
Database clean-up: purge messages
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24541: Purge old messages
Bug-24541-Purge-old-messages.patch (text/plain), 3.86 KB, created by
Bernardo Gonzalez Kriegel
on 2020-03-24 11:22:32 UTC
(
hide
)
Description:
Bug 24541: Purge old messages
Filename:
MIME Type:
Creator:
Bernardo Gonzalez Kriegel
Created:
2020-03-24 11:22:32 UTC
Size:
3.86 KB
patch
obsolete
>From e2fd6864774bade6ba16e298c45d9ddedf07d182 Mon Sep 17 00:00:00 2001 >From: Didier Gautheron <didier.gautheron@biblibre.com> >Date: Thu, 30 Jan 2020 10:35:31 +0100 >Subject: [PATCH] Bug 24541: Purge old messages > >misc/cronjobs/cleanup_database.pl provides some database cleanup. > >This patch adds cleanup for messages table. > >Test plan : >- Count messages : select count(*),date(message_date) from messages group by date(message_date); >- Run cleanup : misc/cronjobs/cleanup_database.pl -v --messages 365 >- Recount messages > >Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com> >Works Ok, no errors. >--- > misc/cronjobs/cleanup_database.pl | 19 +++++++++++++++++++ > 1 file changed, 19 insertions(+) > >diff --git a/misc/cronjobs/cleanup_database.pl b/misc/cronjobs/cleanup_database.pl >index a1a9cae442..b3002699e6 100755 >--- a/misc/cronjobs/cleanup_database.pl >+++ b/misc/cronjobs/cleanup_database.pl >@@ -23,6 +23,7 @@ use constant DEFAULT_ZEBRAQ_PURGEDAYS => 30; > use constant DEFAULT_MAIL_PURGEDAYS => 30; > use constant DEFAULT_IMPORT_PURGEDAYS => 60; > use constant DEFAULT_LOGS_PURGEDAYS => 180; >+use constant DEFAULT_MESSAGES_PURGEDAYS => 365; > use constant DEFAULT_SEARCHHISTORY_PURGEDAYS => 30; > use constant DEFAULT_SHARE_INVITATION_EXPIRY_DAYS => 14; > use constant DEFAULT_DEBARMENTS_PURGEDAYS => 30; >@@ -59,6 +60,8 @@ Usage: $0 [-h|--help] [--sessions] [--sessdays DAYS] [-v|--verbose] [--zebraqueu > -m --mail DAYS purge items from the mail queue that are older than DAYS days. > Defaults to 30 days if no days specified. > --merged purged completed entries from need_merge_authorities. >+ --messages DAYS purge entries from messages table older than DAYS days. >+ Defaults to 365 days if no days specified. > --import DAYS purge records from import tables older than DAYS days. > Defaults to 60 days if no days specified. > --z3950 purge records from import tables that are the result >@@ -122,6 +125,7 @@ my $pDeletedPatrons; > my $pOldIssues; > my $pOldReserves; > my $pTransfers; >+my $pMessages; > > GetOptions( > 'h|help' => \$help, >@@ -134,6 +138,7 @@ GetOptions( > 'import:i' => \$pImport, > 'z3950' => \$pZ3950, > 'logs:i' => \$pLogs, >+ 'messages:i' => \$pMessages, > 'fees:i' => \$fees_days, > 'searchhistory:i' => \$pSearchhistory, > 'list-invites:i' => \$pListShareInvites, >@@ -163,6 +168,7 @@ $mail = DEFAULT_MAIL_PURGEDAYS if defined($mail) > $pSearchhistory = DEFAULT_SEARCHHISTORY_PURGEDAYS if defined($pSearchhistory) && $pSearchhistory == 0; > $pListShareInvites = DEFAULT_SHARE_INVITATION_EXPIRY_DAYS if defined($pListShareInvites) && $pListShareInvites == 0; > $pDebarments = DEFAULT_DEBARMENTS_PURGEDAYS if defined($pDebarments) && $pDebarments == 0; >+$pMessages = DEFAULT_MESSAGES_PURGEDAYS if defined($pMessages) && $pMessages == 0; > > if ($help) { > usage(0); >@@ -192,6 +198,7 @@ unless ( $sessions > || $pOldIssues > || $pOldReserves > || $pTransfers >+ || $pMessages > ) { > print "You did not specify any cleanup work for the script to do.\n\n"; > usage(1); >@@ -293,6 +300,18 @@ if ($pLogs) { > print "Done with purging action_logs.\n" if $verbose; > } > >+if ($pMessages) { >+ print "Purging records from messages.\n" if $verbose; >+ $sth = $dbh->prepare( >+ q{ >+ DELETE FROM messages >+ WHERE message_date < date_sub(curdate(), INTERVAL ? DAY) >+ } >+ ); >+ $sth->execute($pMessages) or die $dbh->errstr; >+ print "Done with purging messages.\n" if $verbose; >+} >+ > if ($fees_days) { > print "Purging records from accountlines.\n" if $verbose; > purge_zero_balance_fees( $fees_days ); >-- >2.17.1
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 24541
:
98152
|
101509
|
101541
|
107369
|
107415
|
112933
|
114711