Skip to content

Commit

Permalink
Add unfinishedMatches() and finishedMatches()
Browse files Browse the repository at this point in the history
  • Loading branch information
jamuraa committed Mar 15, 2013
1 parent bebc09c commit 723ca6c
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions models/Event.php
Expand Up @@ -1143,4 +1143,48 @@ function assignMedalsBySingleElim() {
}
$this->setFinalists($win, $sec, $t4, $t8);
}

function matchesOfType($type) {
$verification = '';
if ($type == 'unfinished') {
$verification = 'unverified';
} elseif ($type == 'finished') {
$verification = 'verified';
}

$db = Database::getConnection();
$stmt = $db->prepare("SELECT m.id FROM matches m, subevents s, events e
WHERE m.subevent = s.id AND s.parent = e.name AND e.name = ? AND
m.verification = ? AND m.round = ? AND s.timing = ? ORDER BY m.verification");
$current_round = $this->current_round;
$timing = 1;
if ($current_round > $this->mainrounds) {
$current_round -= $this->mainrounds;
$timing = 2;
}
$stmt->bind_param("ssdd", $this->name, $verification, $current_round, $timing);
$stmt->execute();
$stmt->bind_result($matchid);

$mids = array();
while ($stmt->fetch()) {
$mids[] = $matchid;
}
$stmt->close();

$matches = array();
foreach ($mids as $mid) {
$matches[] = new Match($mid);
}

return $matches;
}

function unfinishedMatches() {
matchesOfType('unfinished');
}

function finishedMatches() {
matchesOfType('finished');
}
}

0 comments on commit 723ca6c

Please sign in to comment.