mirror of
https://github.com/sigmasternchen/mobmash.click
synced 2025-03-14 23:59:01 +00:00
feat: Add housekeeping bin + slight restructure of cron jobs
This commit is contained in:
parent
d8efb0c2cd
commit
3ade121615
6 changed files with 45 additions and 1 deletions
5
bin/cron/daily.php
Normal file
5
bin/cron/daily.php
Normal file
|
@ -0,0 +1,5 @@
|
|||
<?php
|
||||
|
||||
require_once __DIR__ . '/updateCache.php';
|
||||
|
||||
require_once __DIR__ . '/housekeeping.php';
|
12
bin/cron/housekeeping.php
Normal file
12
bin/cron/housekeeping.php
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
|
||||
require_once __DIR__ . "/../../core.php";
|
||||
require_once __DIR__ . "/../../lib/housekeeping.php";
|
||||
|
||||
echo "Removing old session IDs from match table...";
|
||||
removeOldSessionIDs();
|
||||
|
||||
echo "Removing old audit logs...";
|
||||
removeOldAuditLogs();
|
||||
|
||||
echo "Housekeeping done.";
|
|
@ -3,4 +3,7 @@
|
|||
require_once __DIR__ . "/../../core.php";
|
||||
require_once __DIR__ . "/../../lib/updateCache.php";
|
||||
|
||||
echo "Updating rating cache...";
|
||||
updateCache();
|
||||
|
||||
echo "Done.";
|
||||
|
|
|
@ -46,4 +46,6 @@ echo "Adding to database...\n";
|
|||
foreach ($mobs as &$mob) {
|
||||
echo " ... " . $mob["name"] . "\n";
|
||||
addOrUpdateMob($mob["name"], $mob["filename"]);
|
||||
}
|
||||
}
|
||||
|
||||
echo "Done.";
|
3
bin/cron/weekly.php
Normal file
3
bin/cron/weekly.php
Normal file
|
@ -0,0 +1,3 @@
|
|||
<?php
|
||||
|
||||
require_once __DIR__ . "/updateData.php";
|
19
lib/housekeeping.php
Normal file
19
lib/housekeeping.php
Normal file
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
function removeOldAuditLogs() {
|
||||
global $pdo;
|
||||
$pdo->exec("DELETE FROM mm_audit_log WHERE time < (CURRENT_TIMESTAMP - INTERVAL '6 months')");
|
||||
}
|
||||
|
||||
|
||||
function removeOldSessionIDs() {
|
||||
global $pdo;
|
||||
$pdo->exec(<<<EOF
|
||||
UPDATE mm_matches
|
||||
SET session = NULL
|
||||
WHERE
|
||||
created < (CURRENT_TIMESTAMP - INTERVAL '6 months')
|
||||
AND session IS NOT NULL
|
||||
EOF
|
||||
);
|
||||
}
|
Loading…
Reference in a new issue