<?php
date_default_timezone_set('Europe/Berlin');
// if(function_exists('memprof_enable')) {
//     memprof_enable();
// }


$date = $argv[1];

require_once __DIR__.'/../Application.php';

$config = new Configuration(__DIR__ . '/..');
$app = new Application(__DIR__ . '/..', $config);
$app->registerLogger(new Logger(new Logger_Logfile('/tmp/rebuildrealm.log'), LoggerInterface::DEBUG, $config->getConfig('logging')));
$app->initDb();

$realm = new Model\Realm($app->getDb());
$realms = $realm->getRealmList();

foreach($realms as $realm) {
	/* @var $realm Model\Realm */
    $stats = new Model\RealmStatistics();
    $stats->create($date, $realm->realm, $app->getDb());
}

// if (function_exists('memprof_enable')) {
//     memprof_dump_callgrind(fopen("/tmp/callgrind.out", "w"));
// }

