maintenance.php: use ReportQueries

This commit is contained in:
Zankaria 2024-12-11 16:34:20 +01:00
parent c82a669934
commit 67cf7a464b

View File

@ -3,8 +3,12 @@
* Performs maintenance tasks. Invoke this periodically if the auto_maintenance configuration option is turned off.
*/
use Vichan\Data\ReportQueries;
require dirname(__FILE__) . '/inc/cli.php';
$ctx = Vichan\build_context($config);
echo "Clearing expired bans...\n";
$start = microtime(true);
$deleted_count = Bans::purge($config['require_ban_view'], $config['purge_bans']);
@ -19,7 +23,16 @@ $deleted_count = purge_old_antispam();
$delta = microtime(true) - $start;
echo "Deleted $deleted_count expired antispam in $delta seconds!\n";
$time_tot = $delta;
$deleted_tot = $deleted_count;
$deleted_tot += $deleted_count;
echo "Clearing invalid reports...\n";
$report_queries = $ctx->get(ReportQueries::class);
$start = microtime(true);
$deleted_count = $report_queries->purge();
$delta = microtime(true) - $start;
echo "Deleted $deleted_count invalid reports in $delta seconds!\n";
$time_tot += $delta;
$deleted_tot += $deleted_count;
if ($config['cache']['enabled'] === 'fs') {
$fs_cache = new Vichan\Data\Driver\FsCacheDriver(