<?php

define(
'BASE_PATH',
realpath(__DIR__.'/../..')
);

require_once BASE_PATH.'/config/autoload.php';
require_once BASE_PATH.'/config/bootstrap.php';

$db=\App\Core\Database::getInstance();

echo "AI DECISION BOARD\n";

$db->exec(
"TRUNCATE TABLE ai_decision_board"
);

$rows=
$db->query("
SELECT *
FROM predictive_conference_intelligence
")->fetchAll(PDO::FETCH_ASSOC);

foreach($rows as $r){

    $decision='';

    $priority='Medium';

    if(
        $r['prediction_type']
        ==
        'conference_health_decline'
    ){

        $decision=
        'Improve reviewer assignment quality and expand reviewer pool';

        $priority='High';
    }

    if(
        $r['prediction_type']
        ==
        'reviewer_failure_risk'
    ){

        $decision=
        'Assign additional reviewers and monitor deadlines';

        $priority='Critical';
    }

    $db->prepare("
    INSERT INTO ai_decision_board
    (
        conference_id,
        decision_type,
        priority_level,
        decision_text,
        decision_score
    )
    VALUES
    (
        ?,?,?,?,?
    )
    ")->execute([
        $r['conference_id'],
        $r['prediction_type'],
        $priority,
        $decision,
        $r['prediction_score']
    ]);

}

echo "DONE\n";
