tracker->entries now unix timestamp as key

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

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