summaryrefslogtreecommitdiffstats
path: root/modules-available/statistics/hooks/cron.inc.php
diff options
context:
space:
mode:
Diffstat (limited to 'modules-available/statistics/hooks/cron.inc.php')
-rw-r--r--modules-available/statistics/hooks/cron.inc.php17
1 files changed, 14 insertions, 3 deletions
diff --git a/modules-available/statistics/hooks/cron.inc.php b/modules-available/statistics/hooks/cron.inc.php
index 94c65248..575ab6ba 100644
--- a/modules-available/statistics/hooks/cron.inc.php
+++ b/modules-available/statistics/hooks/cron.inc.php
@@ -1,8 +1,5 @@
<?php
-Database::exec("DELETE FROM statistic WHERE (UNIX_TIMESTAMP() - dateline) > 86400 * 190");
-Database::exec("DELETE FROM machine WHERE (UNIX_TIMESTAMP() - lastseen) > 86400 * 365");
-
function logstats() {
$NOW = time();
$cutoff = $NOW - 86400 * 30;
@@ -15,4 +12,18 @@ function logstats() {
'vals' => $known['val'] . '#' . $on['val'] . '#' . $used['val'],
));
}
+
logstats();
+
+if (mt_rand(1, 10) === 1) {
+ Database::exec("DELETE FROM statistic WHERE (UNIX_TIMESTAMP() - 86400 * 190) > dateline");
+ if (mt_rand(1, 100) === 1) {
+ Database::exec("OPTIMIZE TABLE statistic");
+ }
+}
+if (mt_rand(1, 10) === 1) {
+ Database::exec("DELETE FROM machine WHERE (UNIX_TIMESTAMP() - 86400 * 365) > lastseen");
+ if (mt_rand(1, 100) === 1) {
+ Database::exec("OPTIMIZE TABLE machine");
+ }
+}