Bugzilla – Attachment 91922 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 - statistics
Bug-19008---More-database-cleanups---statistics.patch (text/plain), 3.35 KB, created by
Magnus Enger
on 2019-08-02 12:41:17 UTC
(
hide
)
Description:
Bug 19008 - More database cleanups - statistics
Filename:
MIME Type:
Creator:
Magnus Enger
Created:
2019-08-02 12:41:17 UTC
Size:
3.35 KB
patch
obsolete
>From 69078125d2c76d87b63c7a3bb73a5b833957e389 Mon Sep 17 00:00:00 2001 >From: Fridolin Somers <fridolin.somers@biblibre.com> >Date: Fri, 28 Jul 2017 14:12:22 +0200 >Subject: [PATCH] Bug 19008 - More database cleanups - statistics > >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 statistics table. > >Test plan : >- Count statistics : select count(*),date(datetime) from statistics group by date(datetime); >- Run cleanup : misc/cronjobs/cleanup_database.pl -v --statistics 30 >- Recount statistics > >Signed-off-by: Mark Tompsett <mtompset@hotmail.com> > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > misc/cronjobs/cleanup_database.pl | 18 +++++++++++++++++- > 1 file changed, 17 insertions(+), 1 deletion(-) > >diff --git a/misc/cronjobs/cleanup_database.pl b/misc/cronjobs/cleanup_database.pl >index 975aaabd2a..875a53a986 100755 >--- a/misc/cronjobs/cleanup_database.pl >+++ b/misc/cronjobs/cleanup_database.pl >@@ -45,7 +45,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 ] >+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] > > -h --help prints this help message, and exits, ignoring all > other options >@@ -83,6 +83,7 @@ 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 > --oauth-tokens Delete expired OAuth2 tokens >+ --statistics DAYS Purge entries from statistics older than DAYS days. > USAGE > exit $_[0]; > } >@@ -109,6 +110,7 @@ my $temp_uploads; > my $temp_uploads_days; > my $uploads_missing; > my $oauth_tokens; >+my $pStatistics; > > GetOptions( > 'h|help' => \$help, >@@ -133,6 +135,7 @@ GetOptions( > 'temp-uploads-days:i' => \$temp_uploads_days, > 'uploads-missing:i' => \$uploads_missing, > 'oauth-tokens' => \$oauth_tokens, >+ 'statistics:i' => \$pStatistics, > ) || usage(1); > > # Use default values >@@ -167,6 +170,7 @@ unless ( $sessions > || $temp_uploads > || defined $uploads_missing > || $oauth_tokens >+ || $pStatistics > ) { > print "You did not specify any cleanup work for the script to do.\n\n"; > usage(1); >@@ -353,6 +357,18 @@ if ($oauth_tokens) { > say "Removed $count expired OAuth2 tokens" if $verbose; > } > >+if ($pStatistics) { >+ print "Purging statistics older than $pStatistics days.\n" if $verbose; >+ $sth = $dbh->prepare( >+ q{ >+ DELETE FROM statistics >+ WHERE datetime < DATE_SUB(CURDATE(), INTERVAL ? DAY) >+ } >+ ); >+ $sth->execute($pStatistics); >+ print "Done with purging statistics.\n" if $verbose; >+} >+ > exit(0); > > sub RemoveOldSessions { >-- >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 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