/**
  * torna il numero di interventi sugli atti con un certo tag 
  * tutti gli atti degli argomenti
  *
  * @return void
  * @author Guglielmo Celata
  */
 public function executeQuantodiscusso()
 {
     $interventi_max = sfSupra::getVariable('numero_interventi_max');
     $c = new Criteria();
     $c->addJoin(OppInterventoPeer::ATTO_ID, OppAttoPeer::ID);
     $c->addJoin(TaggingPeer::TAGGABLE_ID, OppAttoPeer::ID);
     $c->add(TaggingPeer::TAGGABLE_MODEL, 'OppAtto');
     $c->add(TaggingPeer::TAG_ID, $this->tag->getId());
     $this->interventi = OppInterventoPeer::doCount($c);
     $this->interventi_perc = 100 * $this->interventi / $interventi_max;
     $this->interventi_avg = sfSupra::getVariable('numero_interventi_avg');
     $this->interventi_avg_perc = 100 * $this->interventi_avg / $interventi_max;
 }
define('SF_DEBUG', false);
require_once SF_ROOT_DIR . DIRECTORY_SEPARATOR . 'apps' . DIRECTORY_SEPARATOR . SF_APP . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php';
sfContext::getInstance();
echo "starting\n";
$con = Propel::getConnection(TagPeer::DATABASE_NAME);
$c = new Criteria(TagPeer::DATABASE_NAME);
$argomenti = TagPeer::doSelect($c, $con);
$ninterventi_tot = 0;
$ninterventi_max = 0;
foreach ($argomenti as $a) {
    echo $a->getTripleValue() . ": ";
    $c = new Criteria(TagPeer::DATABASE_NAME);
    $c->addJoin(OppInterventoPeer::ATTO_ID, OppAttoPeer::ID);
    $c->addJoin(TaggingPeer::TAGGABLE_ID, OppAttoPeer::ID);
    $c->add(TaggingPeer::TAGGABLE_MODEL, 'OppAtto');
    $c->add(TaggingPeer::TAG_ID, $a->getId());
    $ninterventi = OppInterventoPeer::doCount($c, $con);
    $ninterventi_tot += $ninterventi;
    if ($ninterventi > $ninterventi_max) {
        $ninterventi_max = $ninterventi;
    }
    echo " {$ninterventi} ({$ninterventi_max})\n";
}
$ninterventi_avg = $ninterventi_tot / count($argomenti);
echo "found:\n";
printf("n_interventi_max: {$ninterventi_max}, n_interventi_tot: {$ninterventi_tot}, n_interventi_avg: {$ninterventi_avg}\n");
echo "storing in the supra storage\n";
sfSupra::setVariable('numero_interventi_max', $ninterventi_max);
sfSupra::setVariable('numero_interventi_tot', $ninterventi_tot);
sfSupra::setVariable('numero_interventi_avg', $ninterventi_avg);
echo "done\n";
sfContext::getInstance();
$t = new lime_test(11, new lime_output_color());
$t->diag('unit test to verify the SupraVariables plugin');
$t->diag('Test a string');
sfSupra::setVariable('prova', 'pippo');
$prova = sfSupra::getVariable('prova');
$t->ok(is_string($prova), 'a string was stored');
$t->ok($prova == 'pippo', 'the correct value was retrieved');
$t->diag('Test an integer');
sfSupra::setVariable('a', 123);
$a = sfSupra::getVariable('a');
$t->ok(is_int($a), 'an integer was stored');
$t->ok($a == 123, 'the correct value was retrieved');
$t->diag('Test a float and overwriting');
sfSupra::setVariable('a', 123.5);
$a = sfSupra::getVariable('a');
$t->ok(is_float($a), 'a float was stored');
$t->ok($a == 123.5, 'the correct value was retrieved');
$t->diag('Test booleans');
sfSupra::setVariable('b', true);
sfSupra::setVariable('c', false);
$b = sfSupra::getVariable('b');
$c = sfSupra::getVariable('c');
$t->ok(is_bool($b) && is_bool($c), 'boolean s were stored');
$t->ok($b == true && $c == false, 'the correct values were retrieved');
$t->diag('Test complex variables');
sfSupra::setVariable('o', array("one" => 5, "two" => 7));
$o = sfSupra::getVariable('o');
$t->ok(is_array($o), 'an array was stored');
$t->ok(count($o) == 2, 'the length of the array is 2');
$t->ok($o['one'] == 5 && $o['two'] == 7, 'the corrected values were retrieved');