<?php require_once '../init.php'; $mdb = new Mdb(); $old = $mdb->now(3600 * 3); // 8 hours $timer = new Timer(); $queueAllis = new RedisTimeQueue('tqAlliances', 9600); $i = date('i'); if ($i == 45) { $allis = $mdb->find('information', ['type' => 'allianceID']); foreach ($allis as $alli) { $queueAllis->add($alli['id']); } } while ($timer->stop() <= 55000) { sleep(1); $id = (int) $queueAllis->next(false); if ($id == null) { exit; } $alliance = $mdb->findDoc('information', ['type' => 'allianceID', 'id' => $id]); $id = $alliance['id']; $name = $alliance['name']; $currentInfo = $mdb->findDoc('information', ['type' => 'alliance', 'id' => $id]); $alliCrest = CrestTools::getJSON("https://public-crest.eveonline.com/alliances/{$id}/"); if ($alliCrest == null || !isset($alliCrest['name'])) { $mdb->set('information', ['type' => 'alliance', 'id' => $id], ['lastApiUpdate' => $mdb->now()]); continue; } $update = [];
if ($hour != 4) { exit; } if ($minute != 0) { exit; } $mdb = new Mdb(); $types = ['characterID', 'corporationID', 'allianceID', 'factionID', 'groupID', 'shipTypeID', 'solarSystemID', 'regionID']; $timer = new Timer(); $ninetyDayKillID = MongoFilter::getKillIDFromTime(time() - 90 * 86400); $date = new MongoDate(strtotime(date('Y-m-d'))); // Clear out ranks more than two weeks old $mdb->remove('ranksProgress', ['date' => ['$lt' => $mdb->now(-86400 * 14)]]); foreach ($types as $type) { Util::out("Started recent calcs for {$type}"); $calcStats = $mdb->find('information', ['type' => $type]); foreach ($calcStats as $row) { calcStats($row, $ninetyDayKillID); } Util::out("Completed recent calcs for {$type}"); } function calcStats($row, $ninetyDayKillID) { global $mdb, $debug; $type = $row['type']; $id = $row['id']; $killID = (int) @$row['killID']; $key = ['type' => $type, 'id' => $id]; if ($killID < $ninetyDayKillID) { $mdb->getCollection('statistics')->update($key, ['$unset' => ['recentShipsLost' => 1, 'recentPointsLost' => 1, 'recentIskLost' => 1, 'recentShipsDestroyed' => 1, 'recentPointsDestroyed' => 1, 'recentIskDestroyed' => 1, 'recentOverallRank' => 1, 'recentOverallScore' => 1]]); return;
<?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'];