<?php

namespace App\Commands;

use CodeIgniter\CLI\BaseCommand;
use CodeIgniter\CLI\CLI;

class TibaLetaMaintenance extends BaseCommand
{
    protected $group='TibaLeta'; protected $name='tibaleta:maintenance'; protected $description='Runs lightweight recurring data maintenance.';
    public function run(array $params)
    {
        $db=db_connect(); $cutoff=date('Y-m-d H:i:s',time()-86400*90);
        $db->table('practitioner_locations')->where('is_current',0)->where('captured_at <',$cutoff)->delete();
        CLI::write('TibaLeta maintenance completed.','green');
    }
}
