diff --git a/app/cron.ini b/app/cron.ini index 9846d723..f8aa8d91 100644 --- a/app/cron.ini +++ b/app/cron.ini @@ -56,5 +56,8 @@ deleteExpiredCacheData = Cron\Cache->deleteExpiredData, @downtime ; delete old statistics (activity log) data deleteStatisticsData = Cron\StatisticsUpdate->deleteStatisticsData, @weekly +; updates small amount of static system data from CCP API +updateUniverseSystems = Cron\Universe->updateUniverseSystems, @instant + ; setup universe DB with static data from ESI -setup = Cron\Universe->setup, @instant \ No newline at end of file +;setup = Cron\Universe->setup, @instant \ No newline at end of file diff --git a/app/main/controller/ccp/universe.php b/app/main/controller/ccp/universe.php index ee81d774..bc33e0f7 100644 --- a/app/main/controller/ccp/universe.php +++ b/app/main/controller/ccp/universe.php @@ -14,18 +14,6 @@ use Model; class Universe extends Controller { - /** - * Set up "Universe" Database - * @param \Base $f3 - * @throws \Exception - */ - public function setupDB(\Base $f3){ - //$this->setupWormholes($f3); - //var_dump($this->getSystemsIndex()); - //var_dump($this->getSystemData(30000001)); - //var_dump($this->getSystemData(30000002)); - //var_dump($this->getSystemData('Lashesih')); - } /* currently not used protected function setupRegions(\Base $f3){ diff --git a/app/main/cron/universe.php b/app/main/cron/universe.php index d2797233..7ff0613a 100644 --- a/app/main/cron/universe.php +++ b/app/main/cron/universe.php @@ -10,7 +10,7 @@ namespace Cron; use Model; -class Universe { +class Universe extends AbstractCron { const LOG_TEXT = '%s type: %s %s/%s peak: %s total: %s msg: %s'; @@ -242,5 +242,23 @@ class Universe { $this->formatSeconds(microtime(true) - $timeTotalStart), $msg) ); } + /** + * update static universe system data from ESI + * -> updates small chunk of systems at once + * >> php index.php "/cron/updateUniverseSystems" + * @param \Base $f3 + * @throws \Exception + */ + function updateUniverseSystems(\Base $f3){ + $this->setMaxExecutionTime(); + + $system = Model\Universe\BasicUniverseModel::getNew('SystemModel'); + $systems = $system->find( null, ['order' => 'updated', 'limit' => 2]); + if($systems){ + foreach ($systems as $system){ + $system->updateModel(); + } + } + } } \ No newline at end of file diff --git a/app/main/model/universe/systemmodel.php b/app/main/model/universe/systemmodel.php index e46f668c..0756daac 100644 --- a/app/main/model/universe/systemmodel.php +++ b/app/main/model/universe/systemmodel.php @@ -317,6 +317,16 @@ class SystemModel extends BasicUniverseModel { return $stargatesData; } + /** + * update system from ESI + */ + public function updateModel(){ + if( !$this->dry() ){ + $this->loadData($this->_id); + $this->loadPlanetsData(); + } + } + /** * @param int $id * @param string $accessToken