Bugzilla – Attachment 71772 Details for
Bug 19008
Add more options to cleanup database script
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19008 - More database cleanups - deleted catalog
Bug-19008---More-database-cleanups---deleted-catal.patch (text/plain), 4.27 KB, created by
Kyle M Hall (khall)
on 2018-02-16 13:56:26 UTC
(
hide
)
Description:
Bug 19008 - More database cleanups - deleted catalog
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2018-02-16 13:56:26 UTC
Size:
4.27 KB
patch
obsolete
>From a93d5ec4b2aef99ada9022d311aad157ce7cf346 Mon Sep 17 00:00:00 2001 >From: Fridolin Somers <fridolin.somers@biblibre.com> >Date: Fri, 28 Jul 2017 14:05:03 +0200 >Subject: [PATCH] Bug 19008 - More database cleanups - deleted catalog > >misc/cronjobs/cleanup_database.pl provides some database cleanup. >Yet some tables that could need cleanup are not in this script. > >This patch adds cleanup for deleted catalog tables. >Note that deletedbiblio_metadata is managed by foreign key on biblionumber. > >Test plan : >- Count : >select count(*),year(timestamp) from deleteditems group by year(timestamp); >select count(*),year(timestamp) from deletedbiblio group by year(timestamp); >select count(*),year(timestamp) from deletedbiblioitems group by year(timestamp); >- Run cleanup : misc/cronjobs/cleanup_database.pl -v --deleted-catalog 30 >- Recount > >Signed-off-by: Mark Tompsett <mtompset@hotmail.com> > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > misc/cronjobs/cleanup_database.pl | 34 +++++++++++++++++++++++++++++++++- > 1 file changed, 33 insertions(+), 1 deletion(-) > >diff --git a/misc/cronjobs/cleanup_database.pl b/misc/cronjobs/cleanup_database.pl >index f1e093b..f503bdc 100755 >--- a/misc/cronjobs/cleanup_database.pl >+++ b/misc/cronjobs/cleanup_database.pl >@@ -44,7 +44,7 @@ use Koha::UploadedFiles; > > sub usage { > print STDERR <<USAGE; >-Usage: $0 [-h|--help] [--sessions] [--sessdays DAYS] [-v|--verbose] [--zebraqueue DAYS] [-m|--mail] [--merged] [--import DAYS] [--logs DAYS] [--searchhistory DAYS] [--restrictions DAYS] [--all-restrictions] [--fees DAYS] [--temp-uploads] [--temp-uploads-days DAYS] [--uploads-missing 0|1 ] [--statistics DAYS] >+Usage: $0 [-h|--help] [--sessions] [--sessdays DAYS] [-v|--verbose] [--zebraqueue DAYS] [-m|--mail] [--merged] [--import DAYS] [--logs DAYS] [--searchhistory DAYS] [--restrictions DAYS] [--all-restrictions] [--fees DAYS] [--temp-uploads] [--temp-uploads-days DAYS] [--uploads-missing 0|1 ] [--statistics DAYS] [--deleted-catalog DAYS] > > -h --help prints this help message, and exits, ignoring all > other options >@@ -85,6 +85,8 @@ Usage: $0 [-h|--help] [--sessions] [--sessdays DAYS] [-v|--verbose] [--zebraqueu > --temp-uploads-days DAYS Override the corresponding preference value. > --uploads-missing FLAG Delete upload records for missing files when FLAG is true, count them otherwise > --statistics DAYS Purge entries from statistics older than DAYS days. >+ --deleted-catalog DAYS Purge deleted catalog older than DAYS >+ in tables deleteditems, deletedbiblioitems, deletedbiblio_metadata and deletedbiblio > USAGE > exit $_[0]; > } >@@ -111,6 +113,7 @@ my $temp_uploads; > my $temp_uploads_days; > my $uploads_missing; > my $pStatistics; >+my $pDeletedCatalog; > > GetOptions( > 'h|help' => \$help, >@@ -135,6 +138,7 @@ GetOptions( > 'temp-uploads-days:i' => \$temp_uploads_days, > 'uploads-missing:i' => \$uploads_missing, > 'statistics:i' => \$pStatistics, >+ 'deleted-catalog:i' => \$pDeletedCatalog, > ) || usage(1); > > # Use default values >@@ -169,6 +173,7 @@ unless ( $sessions > || $temp_uploads > || defined $uploads_missing > || $pStatistics >+ || $pDeletedCatalog > ) { > print "You did not specify any cleanup work for the script to do.\n\n"; > usage(1); >@@ -352,6 +357,33 @@ if ($pStatistics) { > print "Done with purging statistics.\n" if $verbose; > } > >+if ($pDeletedCatalog) { >+ print "Purging deleted catalog older than $pDeletedCatalog days.\n" if $verbose; >+ my $sth1 = $dbh->prepare( >+ q{ >+ DELETE FROM deleteditems >+ WHERE timestamp < DATE_SUB(CURDATE(), INTERVAL ? DAY) >+ } >+ ); >+ my $sth2 = $dbh->prepare( >+ q{ >+ DELETE FROM deletedbiblioitems >+ WHERE timestamp < DATE_SUB(CURDATE(), INTERVAL ? DAY) >+ } >+ ); >+ my $sth3 = $dbh->prepare( >+ q{ >+ DELETE FROM deletedbiblio >+ WHERE timestamp < DATE_SUB(CURDATE(), INTERVAL ? DAY) >+ } >+ ); >+ # deletedbiblio_metadata is managed by FK with deletedbiblio >+ $sth1->execute($pDeletedCatalog); >+ $sth2->execute($pDeletedCatalog); >+ $sth3->execute($pDeletedCatalog); >+ print "Done with purging deleted catalog.\n" if $verbose; >+} >+ > exit(0); > > sub RemoveOldSessions { >-- >2.10.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 19008
:
65351
|
65352
|
65353
|
65354
|
65355
|
65356
|
68491
|
68492
|
68493
|
68494
|
68495
|
68496
|
71771
|
71772
|
71773
|
71774
|
71775
|
71776
|
91922
|
91923
|
91924
|
91925
|
91926
|
91927
|
91928
|
98373
|
98374
|
98375
|
98376
|
98377
|
98378
|
98379
|
98380