<?php
require __DIR__ . '/../api/bootstrap.php';

use App\Core\Database;
use App\Services\PhotoVotingService;

$pdo = Database::connection();
$stmt = $pdo->query('SELECT id FROM walks WHERE voting_status = "open" AND voting_deadline IS NOT NULL AND voting_deadline < NOW()');
$walkIds = $stmt->fetchAll(PDO::FETCH_COLUMN);
$svc = new PhotoVotingService();
foreach ($walkIds as $walkId) {
    $svc->closeContest((int)$walkId);
}
echo 'Closed ' . count($walkIds) . ' photo contest(s).' . PHP_EOL;
