Ejemplo n.º 1
0
 /**
  * Performs facilities (outposts) update
  *
  * @param bool $verbose whether info should be printed to console
  *
  * @return void
  */
 protected function updateFacilities($verbose)
 {
     //get most recent update date
     $res = static::$sde->query("SELECT UNIX_TIMESTAMP(lastUpdate) as lastUpdateTs\n            FROM " . Config::getIveeDbName() . ".trackedCrestUpdates\n            WHERE name = 'facilities';");
     if ($res->num_rows > 0) {
         $lastUpdateTs = (int) $res->fetch_assoc()['lastUpdateTs'];
     } else {
         $lastUpdateTs = 0;
     }
     //if roughly three hours passed, do the update
     if (time() - $lastUpdateTs > 10000) {
         $crestFacilitiesUpdaterClass = Config::getIveeClassName('CrestFacilitiesUpdater');
         $crestFacilitiesUpdaterClass::doUpdate($this->endpointHandler, $verbose);
         $sql = \iveeCore\SDE::makeUpsertQuery(Config::getIveeDbName() . '.trackedCrestUpdates', array('name' => 'facilities', 'lastUpdate' => date('Y-m-d H:i:s', time())), array('lastUpdate' => date('Y-m-d H:i:s', time())));
         static::$sde->multiQuery($sql . ' COMMIT;');
     } elseif ($verbose) {
         echo "Facilities data still up-to-date, skipping.\n";
     }
 }
Ejemplo n.º 2
0
 /**
  * Sends buffered queries to DB and commits them, then clears the buffer.
  *
  * @return void
  */
 protected function commitSql()
 {
     $this->lastCommitTs = time();
     static::$sde->multiQuery($this->sqlInsertBuffer . 'COMMIT;');
     $this->sqlInsertBuffer = '';
 }