27 lines
645 B
PHP
27 lines
645 B
PHP
|
<?php $app = require '../../app/inc.php';
|
||
|
/**
|
||
|
* We originally wanted to use SSE for this, but the hosting provider
|
||
|
* did not support that so we resorted to simple polling instead
|
||
|
*/
|
||
|
|
||
|
use App\Teamtable\TeamMapper;
|
||
|
use App\Timetable\TimeMapper;
|
||
|
|
||
|
$teamMapper = new TimeMapper($app->database->conn);
|
||
|
$timeMapper = new TimeMapper($app->database->conn);
|
||
|
|
||
|
$prev_hash = (int)filter_input(INPUT_GET, 'hash');
|
||
|
|
||
|
$times = $timeMapper->getAll();
|
||
|
|
||
|
$hash = crc32(serialize($timeMapper->getAll()));
|
||
|
|
||
|
if ($prev_hash !== $hash)
|
||
|
{
|
||
|
$app->api([
|
||
|
"hash" => $hash,
|
||
|
"data" => $times
|
||
|
]);
|
||
|
}
|
||
|
// return nothing
|
||
|
http_response_code(204);
|