Util::out("Starting recent ranking for {$type}"); $size = $mdb->count('statistics', ['type' => $type]); $rankingIDs = []; foreach ($categories as $category) { for ($i = 0; $i <= 1; ++$i) { $field = $category . ($i == 0 ? 'Destroyed' : 'Lost'); $currentValue = -1; $currentRank = 0; $allIDs = $mdb->find('statistics', ['type' => $type], ["recent{$field}" => -1], null, ['months' => 0, 'groups' => 0]); $currentRank = 0; foreach ($allIDs as $row) { if (!isset($row["recent{$field}"])) { continue; } ++$currentRank; $mdb->getCollection('statistics')->update($row, ['$set' => ["recent{$field}Rank" => $currentRank]]); } } } $size = $mdb->count('statistics', ['type' => $type]); $counter = 0; $cursor = $mdb->find('statistics', ['type' => $type], [], null, ['months' => 0, 'groups' => 0]); foreach ($cursor as $row) { ++$counter; $id = $row['id']; $shipsDestroyed = getValue($row, 'recentShipsDestroyed', $size); $shipsDestroyedRank = getValue($row, 'recentShipsDestroyedRank', $size); $shipsLost = getValue($row, 'recentShipsLost', $size); $shipsLostRank = getValue($row, 'recentShipsLostRank', $size); $shipsEff = $shipsDestroyed / ($shipsDestroyed + $shipsLost); $iskDestroyed = getValue($row, 'recentIskDestroyed', $size);
<?php require_once '../init.php'; $mdb = new Mdb(); $old = $mdb->now(3600 * 3); // 8 hours $timer = new Timer(); $mdb->getCollection('information')->update(['type' => 'allianceID', 'lastApiUpdate' => null], ['$set' => ['lastApiUpdate' => new MongoDate(2)]], ['multiple' => true]); $alliances = $mdb->find('information', ['type' => 'allianceID', 'lastApiUpdate' => ['$lt' => $old]], ['lastApiUpdate' => 1], 100); foreach ($alliances as $alliance) { if (Util::exitNow() || $timer->stop() > 110000) { exit; } $id = $alliance['id']; $name = $alliance['name']; //echo "$id $name\n"; $currentInfo = $mdb->findDoc('information', ['type' => 'alliance', 'id' => $id]); if (false && @$currentInfo['deleted'] == true) { $mdb->set('information', ['type' => 'alliance', 'id' => $id], ['lastApiUpdate' => $mdb->now()]); continue; } $alliCrest = CrestTools::getJSON("https://public-crest.eveonline.com/alliances/{$id}/"); if ($alliCrest == null || !isset($alliCrest['name'])) { sleep(1); $mdb->set('information', ['type' => 'alliance', 'id' => $id], ['lastApiUpdate' => $mdb->now()]); continue; } $update = []; $update['lastApiUpdate'] = $mdb->now(); $update['corpCount'] = (int) $alliCrest['corporationsCount']; $update['executorCorpID'] = (int) $alliCrest['executorCorporation']['id'];