Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions routes/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var uuid = require('node-uuid')
module.exports = function(app) {
// JSON API
app.get('/api/stats/:id', statsShow);
app.get('/api/matches', matches);
app.get('/api/matches/:limit', matches);
app.get('/api/player/:id', player);
app.get('/api/player/:id/matches', playerMatches);
app.get('/api/playersearch', playerSearch);
Expand Down Expand Up @@ -74,9 +74,14 @@ var statsShow = function(req, res) {
};

var matches = function(req, res) {
var limitCount = req.params.limit;
if (limitCount < 1 || limitCount == null) {
limitCount = 12; //Default Value if one is not specified
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need a maximum on this value.
How about adding this line here:
limitCount = Math.min(limitCount, 100);

limitCount = Math.min(limitCount, 100); //Limits Count to a Maximum of 100
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the Maximum Value here to allow for a limit of a maximum of 100 matches.

Stats.find({})
.sort({_id:-1})
.limit(12)
.limit(limitCount)
.select('hostname redname bluname redCountry bluCountry isLive')
.lean()
.exec(function(err, matches) {
Expand Down