Skip to content

Commit

Permalink
add endpoint to list pro matches
Browse files Browse the repository at this point in the history
  • Loading branch information
howardchung committed Jun 19, 2016
1 parent 48b06f1 commit a95f2c3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
20 changes: 19 additions & 1 deletion routes/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,25 @@ module.exports = function(db, redis, cassandra)
*/
api.get('/match_logs/:match_id', function(req, res, cb)
{
db.raw(`SELECT * FROM match_logs WHERE match_id = ? ORDER BY time asc`, [req.params.match_id]).asCallback(function(err, result)
db.raw(`SELECT * FROM match_logs WHERE match_id = ? ORDER BY time ASC`, [req.params.match_id]).asCallback(function(err, result)
{
if (err)
{
return cb(err);
}
res.json(result.rows);
});
});
api.get('/pro_matches', function(req, res, cb)
{
db.raw(`
SELECT match_id, start_time, duration, ma.leagueid, name
FROM matches ma
JOIN leagues le
ON ma.leagueid = le.leagueid
WHERE ma.leagueid > 0
ORDER BY match_id DESC
`).asCallback(function(err, result)
{
if (err)
{
Expand Down
1 change: 1 addition & 0 deletions sql/create_tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ CREATE TABLE matches (
teamfights json[],
version integer
);
CREATE INDEX on matches(leagueid) WHERE leagueid > 0;

CREATE TABLE player_matches (
PRIMARY KEY(match_id, player_slot),
Expand Down

0 comments on commit a95f2c3

Please sign in to comment.