<?php /* * This file is part of the Arnapou FileStore package. * * (c) Arnaud Buathier <*****@*****.**> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ include_once __DIR__ . '/../vendor/autoload.php'; Arnapou\GW2Tools\Service::getInstance(); use Arnapou\GW2Tools\User; /* * STATISTICS */ foreach (User::getConnection()->query("SELECT * FROM `" . User::table() . "`") as $row) { try { $user = new User($row); $account = $user->checkAccount(); if (empty($account)) { continue; } $account->calculateStatistics(); } catch (\Exception $ex) { echo $user->getAccount()->getName() . " " . $ex->getMessage() . "\n"; } }
/** * * @return array */ public function getDatasetUsers() { $cacheKey = 'percentile/users_connections/' . ($this->account ? $this->account->getName() : ''); return $this->cacheGet($cacheKey, function () { $array = $this->cacheGet('rawpercentile/users_connections', function () { $conn = User::getConnection(); $sql = "SELECT " . time() . " - `lastaccess` as n FROM `tokens` ORDER BY n"; $array = []; foreach ($conn->query($sql) as $row) { $array[] = floor($row['n'] / 86400); } return $array; }, 3600); return $this->doCalcPercentiles($array); }, 900); }
<?php /* * This file is part of the Arnapou FileStore package. * * (c) Arnaud Buathier <*****@*****.**> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ include_once __DIR__ . '/../vendor/autoload.php'; Arnapou\GW2Tools\Service::getInstance(); use Arnapou\GW2Tools\User; /* * DELETE OLD USERS */ $conn = User::getConnection(); // clean old non accessed codes / users : more than one year $conn->executeDelete(User::table(), 'lastaccess < ' . (time() - 365 * 86400)); //// //// 2015-10-04 //// disabled because of some weird issues on the api when doing a lot of requests //// I should look further before reactivating it //// //foreach ($conn->query("SELECT * FROM `" . User::table() . "`") as $row) { // $user = new User($row); // $user->checkAccount(); // automatic delete if error with token //}