示例#1
0
 public static function getMatchesAtEvent($eventId, $update = false)
 {
     if ($update) {
         require_once './eagle/utils/Downloader.php';
         Downloader::getMatchesAtEvent($eventId);
     }
     $filename = './data/' . $eventId . '/matches.json';
     return self::readFile($filename);
 }
示例#2
0
 });
 $this->get('/match', function ($req, $res, $args) {
     $this->view->render($res, 'matchScoutingHome.html', ['title' => 'Match Scouting', 'user' => Auth::getLoggedInUser()]);
 });
 $this->post('/match', function ($req, $res, $args) {
     $str = '2016';
     $str .= $_POST['competition'];
     $str .= '_';
     $str .= $_POST['matchType'];
     if ($_POST['matchType'] != 'q') {
         $str .= '1';
     }
     $str .= 'm';
     $str .= $_POST['matchNumber'];
     $event = split('_', $str)[0];
     Downloader::getMatchesAtEvent($event);
     return $res->withStatus(302)->withHeader('Location', '/scouting/match/new/' . $str);
 });
 $this->post('/match/new', function ($req, $res, $args) {
     $comment = new Comment();
     $comment->user_id = Auth::getLoggedInUser()->id;
     $comment->author = Auth::getLoggedInUser()->name;
     $comment->team_id = $_POST['team_id'];
     $comment->notes = $_POST['notes'];
     $comment->save();
     $match = new MatchScouting();
     $match->team_id = $_POST['team_id'];
     $match->user_id = Auth::getLoggedInUser()->id;
     $match->author = Auth::getLoggedInUser()->name;
     $match->match_id = $_POST['match_id'];
     $match->driver_skill = $_POST['driver_skill'];
示例#3
0
 });
 $this->get('/{event:\\d{4}[A-Za-z]{1,4}}', function ($req, $res, $args) {
     Auth::redirectIfNotLoggedIn();
     $event = FileReader::getEvent($args['event']);
     if (!$event) {
         Downloader::getEvent($args['event']);
         header('Refresh:0');
     }
     $teams = FileReader::getTeamsAtEvent($args['event']);
     if (!count($teams)) {
         Downloader::getTeamsAtEvent($args['event']);
         header('Refresh:0');
     }
     $matches = FileReader::getMatchesAtEvent($args['event']);
     if (!count($matches)) {
         Downloader::getMatchesAtEvent($args['event']);
         header('Refresh:0');
     }
     $types = array('f' => 'Finals', 'sf' => 'Semifinals', 'qf' => 'Quarter Final', 'qm' => 'Qualifier');
     foreach ($matches as $match) {
         $match->match_type = $types[$match->comp_level];
     }
     $rankings = FileReader::getRankingsAtEvent($args['event']);
     if (!count($rankings)) {
         Downloader::getRankingsAtEvent($args['event']);
         header('Refresh:0');
     }
     $dlstats = FileReader::getStatsAtEvent($args['event']);
     if (!$dlstats && !count($dlstats)) {
         Downloader::getStatsAtEvent($args['event']);
         header('Refresh:0');