@@ -, +, @@ - Count statistics : select count(*),date(datetime) from statistics group by date(datetime); - Run cleanup : misc/cronjobs/cleanup_database.pl -v --statistics 30 - Recount statistics --- misc/cronjobs/cleanup_database.pl | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) --- a/misc/cronjobs/cleanup_database.pl +++ a/misc/cronjobs/cleanup_database.pl @@ -44,7 +44,7 @@ use Koha::UploadedFiles; sub usage { print STDERR < \$help, @@ -132,6 +134,7 @@ GetOptions( 'temp-uploads' => \$temp_uploads, 'temp-uploads-days:i' => \$temp_uploads_days, 'uploads-missing:i' => \$uploads_missing, + 'statistics:i' => \$pStatistics, ) || usage(1); # Use default values @@ -165,6 +168,7 @@ unless ( $sessions || $special_holidays_days || $temp_uploads || defined $uploads_missing + || $pStatistics ) { print "You did not specify any cleanup work for the script to do.\n\n"; usage(1); @@ -336,6 +340,18 @@ if( defined $uploads_missing ) { } } +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 { --