/** * main method, performed by CRON */ public function download() { $this->loginToWigle(); $query = $this->downloadQueue->getRandomNotDownloadedRecord(); if (!$query) { return; } $id_download_request = $query->id_download_request; $coords = new Coords($query['lat_start'], $query['lat_end'], $query['lon_start'], $query['lon_end']); $results = $this->getDataFromWigle($coords, (int) $query["from"]); $results_decoded = json_decode($results, true); if ($results_decoded["success"] == true) { // rozparsovat data $data = $this->parseData($results_decoded); $mac_addresses = array(); // vybrat vsechny mac adresy a body nastavit jako hrube foreach ($data as $w) { $mac_addresses[] = $w->getMac(); $w->setCalculated(1); } // ulozit mac adresy k dalsimu zpracovani $this->saveAll2WigleAps($query['id'], $mac_addresses); // ulozit vypoctene body $this->saveAll($data); // transakcne vlozime $this->database->beginTransaction(); $query->update(array("downloaded" => 1, "downloaded_nets_count" => count($mac_addresses), "count_downloaded_observations" => 0)); if ((int) $results_decoded["resultCount"] >= self::WIGLE_MAXIMUM_ROWS) { $this->downloadQueue->addRecord($coords, 0, $id_download_request, (int) $results_decoded["last"]); $this->database->table('download_request')->where('id', $id_download_request)->update(array('total_count' => new SqlLiteral('total_count + 1'))); } $this->database->commit(); } else { $this->logger->addLog(new Log(Log::TYPE_WARNING, 'WIGLE DOWNLOAD', 'moc pozadavku')); } }