/**
* @param InputInterface $input
* @param OutputInterface $out
* @return int
*/
protected function execute(InputInterface $input, OutputInterface $out)
{
$this->outputHeading($out, "Transfer Patterns");
$scanDate = $this->getNextScanDate();
$nonTimetableConnections = $this->outputTask($out, "Loading non-timetable connections", function () use($scanDate) {
return $this->scheduleProvider->getNonTimetableConnections(strtotime($scanDate . " UTC"));
});
$timetables = $this->outputTask($out, "Loading timetables", function () use($scanDate) {
return $this->scheduleProvider->getTimetableConnections(strtotime("{$scanDate} 00:00 UTC"));
});
$interchange = $this->outputTask($out, "Loading interchange", function () {
return $this->scheduleProvider->getInterchangeTimes();
});
$stations = array_keys($this->stationProvider->getLocations());
$persistence = new TransferPatternPersistence($timetables, $nonTimetableConnections, $interchange);
$this->outputTask($out, "Calculating transfer patterns", function () use($stations, $persistence, $scanDate) {
// $persistence->calculateTransferPatternsForStation(call_user_func($this->dbFactory), "MYB", $scanDate);
// return;
$callable = function ($station) use($persistence, $scanDate) {
$persistence->calculateTransferPatternsForStation(call_user_func($this->dbFactory), $station, $scanDate);
};
$this->processManager->process($stations, $callable, $this->forkStrategy);
$this->processManager->wait();
});
$this->setLastScanDate($scanDate);
$this->outputMemoryUsage($out);
return 0;
}