[rakim] data updates...

Chuck Hagenbuch chuck at horde.org
Fri Apr 11 15:08:27 PDT 2003


Since I need valid data to test the reporting/arching code that's coming, I
wrote this script to take my existing test data and add reasonable
queue_create_time, queue_active_time, and queue_exit_time values. I don't
know if any of you have the same need for data so far, but if so, you might
find this useful.

#!/usr/local/bin/php -f
<?php

// Find the base file path of Horde.
@define('HORDE_BASE', dirname(__FILE__) . '/../..');

// Do CLI checks and environment setup first.
require_once HORDE_BASE . '/lib/CLI.php';

// Make sure no one runs this from the web.
if (!Horde_CLI::runningFromCLI()) {
    exit("Must be run from the command line\n");
}

// Load the CLI environment - make sure there's no time limit, init
// some variables, etc.
Horde_CLI::init();

// Now go ahead and load Rakim.
$self_contained_auth = true;
@define('RAKIM_BASE', dirname(__FILE__) . '/..');
require_once RAKIM_BASE . '/lib/base.php';

$data = $db->getAll('SELECT guest_id, guest_login_time, guest_logoff_time
from rakim_guests', DB_FETCHMODE_ASSOC);
foreach ($data as $row) {
    $db->query('UPDATE rakim_queues SET queue_create_time = ' .
$row['guest_login_time'] . ' WHERE queue_create_time = 0 AND guest_id = ' .
$row['guest_id']);
    $db->query('UPDATE rakim_queues SET queue_active_time = ' .
((int)$row['guest_login_time'] + rand(2, 100)) . ' WHERE queue_active_time
IS NULL AND guest_id = ' . $row['guest_id']);
    if (!is_null($row['guest_logoff_time'])) {
        $db->query('UPDATE rakim_queues SET queue_exit_time = ' .
$row['guest_logoff_time'] . ' WHERE queue_exit_time IS NULL AND guest_id =
' . $row['guest_id']);
    }
}


-chuck

--
Charles Hagenbuch, <chuck at horde.org>
"... It is not more light we need, but more warmth! We die of cold, not of
darkness. It is not the night that kills, but the frost." - Miguel de
Unamuno


More information about the rakim mailing list