|
|
|
@ -208,10 +208,20 @@ class Account { |
|
|
|
|
$currentElo->rank = $fetchedElo->rank; |
|
|
|
|
$currentElo->points = $fetchedElo->leaguePoints; |
|
|
|
|
|
|
|
|
|
$date = (new DateTime("now"))->format("Y-m-d H:i:s"); |
|
|
|
|
$eloEntries[$date] = $currentElo; |
|
|
|
|
$latestMatchTimestamp = $this->getLatestMatchTimestamp(); |
|
|
|
|
|
|
|
|
|
$conn = new MySQLConnection(); |
|
|
|
|
$isMatchUnknown = $conn->query(" |
|
|
|
|
SELECT COUNT(date) = 0 AS match_unknown |
|
|
|
|
FROM updates |
|
|
|
|
WHERE date > FROM_UNIXTIME($latestMatchTimestamp) AND status = 'COMPLETE'; |
|
|
|
|
")->fetch_assoc()["match_unknown"]; |
|
|
|
|
|
|
|
|
|
$date = new DateTime(); |
|
|
|
|
if ($isMatchUnknown) |
|
|
|
|
$date->setTimestamp($latestMatchTimestamp); |
|
|
|
|
|
|
|
|
|
$eloEntries[$date->getTimestamp()] = $currentElo; |
|
|
|
|
|
|
|
|
|
$sqlAccountId = $conn->query(" |
|
|
|
|
SELECT id |
|
|
|
@ -224,7 +234,7 @@ class Account { |
|
|
|
|
(accountId, date, tier, `rank`, points) |
|
|
|
|
VALUES (?, ?, ?, ?, ?) |
|
|
|
|
")->execute([ |
|
|
|
|
$sqlAccountId, $date, $currentElo->tier, $currentElo->rank, $currentElo->points |
|
|
|
|
$sqlAccountId, $date->format("Y-m-d H:i:s"), $currentElo->tier, $currentElo->rank, $currentElo->points |
|
|
|
|
]); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -245,6 +255,20 @@ class Account { |
|
|
|
|
WHERE `puuid` = ? |
|
|
|
|
")->execute([$this->gameName, $this->tagLine, $this->puuid]); |
|
|
|
|
} |
|
|
|
|
private function getLatestMatchTimestamp(): int { |
|
|
|
|
$matchIdsRequest = new RiotRequest("lol/match/v5/matches/by-puuid/$this->puuid/ids"); |
|
|
|
|
$matchIdsRequest->useRouting(); |
|
|
|
|
$matchIdsRequest->setQueries([ |
|
|
|
|
"count" => 1, |
|
|
|
|
"queue" => 420 // 5x5 solo queue |
|
|
|
|
]); |
|
|
|
|
$latestMatchId = $matchIdsRequest->run()[0]; |
|
|
|
|
|
|
|
|
|
$latestMatchRequest = new RiotRequest("lol/match/v5/matches/$latestMatchId"); |
|
|
|
|
$latestMatchRequest->useRouting(); |
|
|
|
|
|
|
|
|
|
return intval($latestMatchRequest->run()->info->gameEndTimestamp / 1000); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
class Elo { |
|
|
|
|