$id = $row['id']; $killID = getLatestKillID($type, $id, $ninetyDayKillID); if ($killID < $ninetyDayKillID) { continue; } $types[$type] = true; $key = "tq:ranks:recent:{$type}:{$today}"; $recentKills = getRecent($row['type'], $row['id'], false, $ninetyDayKillID); $recentLosses = getRecent($row['type'], $row['id'], true, $ninetyDayKillID); $multi = $redis->multi(); zAdd($multi, "{$key}:shipsDestroyed", $recentKills['killIDCount'], $id); zAdd($multi, "{$key}:pointsDestroyed", $recentKills['zkb_pointsSum'], $id); zAdd($multi, "{$key}:iskDestroyed", $recentKills['zkb_totalValueSum'], $id); zAdd($multi, "{$key}:shipsLost", $recentLosses['killIDCount'], $id); zAdd($multi, "{$key}:pointsLost", $recentLosses['zkb_pointsSum'], $id); zAdd($multi, "{$key}:iskLost", $recentLosses['zkb_totalValueSum'], $id); $multi->exec(); } Util::out("recent time ranks - second iteration"); foreach ($types as $type => $value) { $key = "tq:ranks:recent:{$type}:{$today}"; $indexKey = "{$key}:shipsDestroyed"; $max = $redis->zCard($indexKey); $redis->del("tq:ranks:recent:{$type}:{$today}"); $it = NULL; while ($arr_matches = $redis->zScan($indexKey, $it)) { foreach ($arr_matches as $id => $score) { $shipsDestroyed = $redis->zScore("{$key}:shipsDestroyed", $id); $shipsDestroyedRank = rankCheck($max, $redis->zRevRank("{$key}:shipsDestroyed", $id)); $shipsLost = $redis->zScore("{$key}:shipsLost", $id); $shipsLostRank = rankCheck($max, $redis->zRevRank("{$key}:shipsLost", $id));
$information = $mdb->getCollection("statistics"); Util::out("Alltime ranks - first iteration"); $types = []; $iter = $information->find(); while ($row = $iter->next()) { $type = $row['type']; $id = $row['id']; $types[$type] = true; $key = "tq:ranks:alltime:{$type}:{$today}"; $multi = $redis->multi(); zAdd($multi, "{$key}:shipsDestroyed", @$row['shipsDestroyed'], $id); zAdd($multi, "{$key}:shipsLost", @$row['shipsLost'], $id); zAdd($multi, "{$key}:pointsDestroyed", @$row['pointsDestroyed'], $id); zAdd($multi, "{$key}:pointsLost", @$row['pointsLost'], $id); zAdd($multi, "{$key}:iskDestroyed", @$row['iskDestroyed'], $id); zAdd($multi, "{$key}:iskLost", @$row['iskLost'], $id); $multi->exec(); } Util::out("Alltime ranks - second iteration"); foreach ($types as $type => $value) { $key = "tq:ranks:alltime:{$type}:{$today}"; $indexKey = "{$key}:shipsDestroyed"; $max = $redis->zCard($indexKey); $redis->del("tq:ranks:alltime:{$type}:{$today}"); $it = NULL; while ($arr_matches = $redis->zScan($indexKey, $it)) { foreach ($arr_matches as $id => $score) { $shipsDestroyed = $redis->zScore("{$key}:shipsDestroyed", $id); $shipsDestroyedRank = rankCheck($max, $redis->zRevRank("{$key}:shipsDestroyed", $id)); $shipsLost = $redis->zScore("{$key}:shipsLost", $id); $shipsLostRank = rankCheck($max, $redis->zRevRank("{$key}:shipsLost", $id));
continue; } $types[$type] = true; $key = "tq:ranks:weekly:{$type}:{$today}"; $weeklyKills = getWeekly($row['type'], $row['id'], false, $ninetyDayKillID); if ($weeklyKills['killIDCount'] == 0) { continue; } $weeklyLosses = getWeekly($row['type'], $row['id'], true, $ninetyDayKillID); $multi = $redis->multi(); zAdd($multi, "{$key}:shipsDestroyed", $weeklyKills['killIDCount'], $id); zAdd($multi, "{$key}:pointsDestroyed", $weeklyKills['zkb_pointsSum'], $id); zAdd($multi, "{$key}:iskDestroyed", $weeklyKills['zkb_totalValueSum'], $id); zAdd($multi, "{$key}:shipsLost", $weeklyLosses['killIDCount'], $id); zAdd($multi, "{$key}:pointsLost", $weeklyLosses['zkb_pointsSum'], $id); zAdd($multi, "{$key}:iskLost", $weeklyLosses['zkb_totalValueSum'], $id); $multi->exec(); } Util::out("weekly time ranks - second iteration"); foreach ($types as $type => $value) { $key = "tq:ranks:weekly:{$type}:{$today}"; $indexKey = "{$key}:shipsDestroyed"; $max = $redis->zCard($indexKey); $redis->del("tq:ranks:weekly:{$type}:{$today}"); $it = NULL; while ($arr_matches = $redis->zScan($indexKey, $it)) { foreach ($arr_matches as $id => $score) { $shipsDestroyed = $redis->zScore("{$key}:shipsDestroyed", $id); $shipsDestroyedRank = rankCheck($max, $redis->zRevRank("{$key}:shipsDestroyed", $id)); $shipsLost = $redis->zScore("{$key}:shipsLost", $id); $shipsLostRank = rankCheck($max, $redis->zRevRank("{$key}:shipsLost", $id));