diff --git a/public/elotracker/Tracker.php b/public/elotracker/Tracker.php index c54bcf5..c98675e 100644 --- a/public/elotracker/Tracker.php +++ b/public/elotracker/Tracker.php @@ -98,10 +98,13 @@ class Tracker { return $progressions; } - public function update(): void { + public function update(callable $progressCallback): void { + $counter = 0; foreach ($this->accounts as $puuid => $account) { $account->update($this->entries[$puuid]); + $counter++; + $progressCallback($counter / sizeof($this->accounts)); } } diff --git a/public/elotracker/update.php b/public/elotracker/update.php index 08e3019..2a00299 100644 --- a/public/elotracker/update.php +++ b/public/elotracker/update.php @@ -1,6 +1,43 @@ query(" + SELECT date + FROM updates + WHERE date > SUBTIME(NOW(), '00:10:00') + LIMIT 1 +"); +if ($result->num_rows > 0) { + sendEvent("forbidden", $result->fetch_assoc()["date"]); + die; +} + +$conn->query("INSERT INTO updates VALUES ()"); + require_once __DIR__."/Tracker.php"; +sendEvent("progress", 0); + $tracker = new Tracker(); -$tracker->update(); \ No newline at end of file +$tracker->update(function($value){ + sendEvent('progress', $value); +}); + +sendEvent("done", "");