function indexNoEventsSeat(Request $request, Application $app)
 {
     $arb = new \com\meetyournextmp\repositories\builders\AreaRepositoryBuilder();
     $arb->setIsMapItAreaOnly(true);
     $arb->setIncludeDeleted(false);
     $arb->setIncludeAreasWithNoEventsOnly(true);
     $arb->setLimit(800);
     $this->parameters['areas'] = $arb->fetchAll();
     return $app['twig']->render('site/help/noevents.seats.html.twig', $this->parameters);
 }
 protected function run()
 {
     $siteRepo = new \repositories\SiteRepository();
     $site = $siteRepo->loadById($this->app['config']->singleSiteID);
     // TODO assumes single site!
     $out = array();
     $erb = new EventRepositoryBuilder();
     $erb->setIncludeDeleted(false);
     $erb->setIncludeCancelled(false);
     $erb->setSite($site);
     $out['countEventsTotal'] = count($erb->fetchAll());
     $erb = new EventRepositoryBuilder();
     $erb->setIncludeDeleted(false);
     $erb->setIncludeCancelled(false);
     $erb->setSite($site);
     $erb->setBefore($this->app['timesource']->getDateTime());
     $out['countEventsBeforeNow'] = count($erb->fetchAll());
     $erb = new EventRepositoryBuilder();
     $erb->setIncludeDeleted(false);
     $erb->setIncludeCancelled(false);
     $erb->setSite($site);
     $erb->setAfterNow();
     $out['countEventsAfterNow'] = count($erb->fetchAll());
     $arb = new \com\meetyournextmp\repositories\builders\AreaRepositoryBuilder();
     $arb->setIsMapItAreaOnly(true);
     $arb->setIncludeDeleted(false);
     $arb->setIncludeAreasWithNoEventsOnly(true);
     $arb->setLimit(800);
     $out['countSeatsWithNoEvents'] = count($arb->fetchAll());
     $areaRepo = new AreaRepository();
     foreach (array(3 => 'countEventsInScotland', 1 => 'countEventsInEngland', 2 => 'countEventsInWales', 4 => 'countEventsInNIreland', 712 => 'countEventsInGreaterLondon') as $areaSlug => $key) {
         $erb = new EventRepositoryBuilder();
         $erb->setIncludeDeleted(false);
         $erb->setIncludeCancelled(false);
         $erb->setSite($site);
         $erb->setArea($areaRepo->loadBySlug($site, $areaSlug));
         $out[$key] = count($erb->fetchAll());
     }
     // =================================== Events by day
     $report = $this->getValueReport('com.meetyournextmp', 'NonDeletedNonCancelledEventsStartAtReport', $this->app);
     $startAt = \TimeSource::getDateTime();
     $startAt->setTime(0, 0, 0);
     $endAt = new \DateTime('2015-05-07 10:00:00');
     $period = "P1D";
     $report->setFilterSiteId($this->app['config']->singleSiteID);
     $reportByTime = new SeriesOfValueByTimeReport($report, $startAt, $endAt, $period);
     $reportByTime->run();
     $out['countEventsByDay'] = array();
     foreach ($reportByTime->getData() as $data) {
         $out['countEventsByDay'][] = array('count' => $data->getData(), 'date' => $data->getLabelStart()->format('D d F Y'));
     }
     // =================================== Users with edits
     $report = $this->getSeriesReport("org.openacalendar", "UsersWithEventsEdited", $this->app);
     $report->run();
     $out['userEventsEdited'] = array();
     foreach ($report->getData() as $data) {
         $out['userEventsEdited'][] = array('count' => $data->getData(), 'userID' => $data->getLabelID(), 'userUserName' => $data->getLabelText());
     }
     //var_dump($out);
     file_put_contents(APP_ROOT_DIR . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . 'numbers.json', json_encode($out));
     return array('result' => 'ok');
 }
$parentAreas = array('England' => null, 'Scotland' => null, 'Wales' => null, 'Northern Ireland' => null);
$arb = new \repositories\builders\AreaRepositoryBuilder();
$arb->setNoParentArea(true);
$arb->setIncludeDeleted(false);
$arb->fetchAll();
foreach ($arb->fetchAll() as $area) {
    foreach ($parentAreas as $key => $value) {
        if ($area->getTitle() == $key) {
            $parentAreas[$key] = $area;
        }
    }
}
$workToDo = array('England' => null, 'Scotland' => null, 'Wales' => null, 'Northern Ireland' => null);
foreach ($parentAreas as $parentArea) {
    print "Parent Area " . $parentArea->getTitle() . "\n";
    $arb = new \com\meetyournextmp\repositories\builders\AreaRepositoryBuilder();
    $arb->setParentArea($parentArea);
    $arb->setLimit(10000);
    foreach ($arb->fetchAll() as $area) {
        if ($area->getParentAreaId() == $parentArea->getId()) {
            print "  -  " . $area->getTitle() . "\n";
            if (considerArea($area, $modeCurrent, $magicWords, $ignoreWords)) {
                print "  -  -  Consider\n";
                $newParentTitle = stripCompassEndOfArea($area, $modeCurrent, $magicWords);
                if (!isset($workToDo[$parentArea->getTitle()][$newParentTitle])) {
                    $workToDo[$parentArea->getTitle()][$newParentTitle] = array();
                }
                $workToDo[$parentArea->getTitle()][$newParentTitle][] = $area;
            }
        }
    }