tracker->entries now unix timestamp as key

main
Benjamin Kraft 3 months ago
parent a23b8504c6
commit 9a0d062b4d
  1. 34
      public/elotracker/Tracker.php

@ -16,6 +16,11 @@ class Tracker {
*/
public array $entries;
/**
* @var Elo[][]
*/
public array $entriesByDateString;
public function __construct() {
$this->conn = new MySQLConnection();
$this->readAccounts();
@ -45,27 +50,30 @@ class Tracker {
ORDER BY accounts.puuid, date
");
$result = [];
$this->entries = [];
$this->entriesByDateString = [];
while ($row = $sql->fetch_assoc()) {
$puuid = $row["puuid"];
$date = $row["date"];
if (!isset($result[$puuid]))
$result[$puuid] = [];
if (!isset($this->entries[$puuid]))
$this->entries[$puuid] = [];
if (!$date)
continue;
if (!isset($this->entriesByDateString[$puuid]))
$this->entriesByDateString[$puuid] = [];
$elo = new Elo();
$elo->tier = $row["tier"];
$elo->rank = $row["rank"];
$elo->points = $row["points"];
if ($dateString = $row["date"]){
$elo = new Elo();
$elo->tier = $row["tier"];
$elo->rank = $row["rank"];
$elo->points = $row["points"];
$result[$puuid][$date] = $elo;
}
$datetime = new DateTime($dateString);
$this->entries[$puuid][$datetime->getTimestamp()] = $elo;
$this->entriesByDateString[$puuid][$dateString] = $elo;
}
$this->entries = $result;
}
}
/**

Loading…
Cancel
Save