1
0
Fork 0

Fix DB query and stats parsing of RegionChecker

master
Anonymous Contributor 2023-09-11 07:29:02 +02:00
parent eb5a850869
commit 8231fbb08c
1 changed files with 6 additions and 2 deletions

View File

@ -15,7 +15,7 @@ class RegionChecker extends CronJob
public function run(): bool
{
$statement = $this->app->db()->prepare("SELECT uuid,regionName,owner_uuid,serverURI,OfflineTimer FROM regions JOIN mcp_regions_info ON regions.uuid = mcp_regions_info.regionID COLLATE utf8mb3_unicode_ci");
$statement = $this->app->db()->prepare("SELECT uuid,regionName,owner_uuid,serverURI,OfflineTimer FROM regions LEFT JOIN mcp_regions_info ON regions.uuid = mcp_regions_info.regionID COLLATE utf8mb3_unicode_ci");
$statement->execute();
while ($row = $statement->fetch()) {
@ -25,6 +25,10 @@ class RegionChecker extends CronJob
$result = curl_exec($curl);
if ($result === false || strlen($result) == 0) {
if ($row['OfflineTimer'] == null) {
continue;
}
$opensim = new OpenSim($this->app->db());
$longOffline = ($row['OfflineTimer'] + 3600) <= time();
@ -46,7 +50,7 @@ class RegionChecker extends CronJob
$regionData = json_decode($result);
$statementAccounts = $this->app->db()->prepare('REPLACE INTO `mcp_regions_info` (`regionID`, `RegionVersion`, `ProcMem`, `Prims`, `SimFPS`, `PhyFPS`, `OfflineTimer`) VALUES (:regionID, :RegionVersion, :ProcMem, :Prims, :SimFPS, :PhyFPS, :OfflineTimer)');
$statementAccounts->execute(['regionID' => $row['uuid'], 'RegionVersion' => $regionData->Version, 'ProcMem' => $regionData->ProcMem, 'Prims' => $regionData->Prims, 'SimFPS' => $regionData->SimFPS, 'PhyFPS' => $regionData->PhyFPS, 'OfflineTimer' => time()]);
$statementAccounts->execute(['regionID' => $row['uuid'], 'RegionVersion' => $regionData->Version, 'ProcMem' => intval(str_replace(',', '', $regionData->ProcMem)), 'Prims' => $regionData->Prims, 'SimFPS' => $regionData->SimFPS, 'PhyFPS' => $regionData->PhyFPS, 'OfflineTimer' => time()]);
}
}