Skip to content
This repository has been archived by the owner on Jan 8, 2022. It is now read-only.

Commit

Permalink
Fixed bug with statistics.champs... routes
Browse files Browse the repository at this point in the history
  • Loading branch information
pradyuman committed Jul 5, 2016
1 parent f56c820 commit 138a145
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
14 changes: 7 additions & 7 deletions lib/stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ function champData(name, cb) {
}

function champMostWins(options, cb) {
var params = utils.cleanParams(null, options, cb);
var params = utils.cleanParams('pass', options, cb);

needle.get(printf("%s/champs/mostWinning?api_key=%s&page=%i&limit=%i", url, _key, params.options.page, params.options.limit), function (err, response) {
if (err) {
Expand All @@ -148,7 +148,7 @@ function champMostWins(options, cb) {
}

function champLeastWins(options, cb) {
var params = utils.cleanParams(null, options, cb);
var params = utils.cleanParams('pass', options, cb);

needle.get(printf("%s/champs/leastWinning?api_key=%s&page=%i&limit=%i", url, _key, params.options.page, params.options.limit), function (err, response) {
if (err) {
Expand All @@ -159,7 +159,7 @@ function champLeastWins(options, cb) {
}

function champMostPlayed(options, cb) {
var params = utils.cleanParams(null, options, cb);
var params = utils.cleanParams('pass', options, cb);

needle.get(printf("%s/champs/mostPlayed?api_key=%s&page=%i&limit=%i", url, _key, params.options.page, params.options.limit), function (err, response) {
if (err) {
Expand All @@ -170,7 +170,7 @@ function champMostPlayed(options, cb) {
}

function champLeastPlayed(options, cb) {
var params = utils.cleanParams(null, options, cb);
var params = utils.cleanParams('pass', options, cb);

needle.get(printf("%s/champs/leastPlayed?api_key=%s&page=%i&limit=%i", url, _key, params.options.page, params.options.limit), function (err, response) {
if (err) {
Expand All @@ -181,7 +181,7 @@ function champLeastPlayed(options, cb) {
}

function champMostBanned(options, cb) {
var params = utils.cleanParams(null, options, cb);
var params = utils.cleanParams('pass', options, cb);

needle.get(printf("%s/champs/mostBanned?api_key=%s&page=%i&limit=%i", url, _key, params.options.page, params.options.limit), function (err, response) {
if (err) {
Expand All @@ -192,7 +192,7 @@ function champMostBanned(options, cb) {
}

function champBestRated(options, cb) {
var params = utils.cleanParams(null, options, cb);
var params = utils.cleanParams('pass', options, cb);

needle.get(printf("%s/champs/bestRated?api_key=%s&page=%i&limit=%i", url, _key, params.options.page, params.options.limit), function (err, response) {
if (err) {
Expand All @@ -203,7 +203,7 @@ function champBestRated(options, cb) {
}

function champWorstRated(options, cb) {
var params = utils.cleanParams(null, options, cb);
var params = utils.cleanParams('pass', options, cb);

needle.get(printf("%s/champs/worstRated?api_key=%s&page=%i&limit=%i", url, _key, params.options.page, params.options.limit), function (err, response) {
if (err) {
Expand Down
7 changes: 6 additions & 1 deletion lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,20 @@ function manageResponse(resp, cb) {
}

function cleanParams (role, options, cb) {
if (!role || typeof(role) !== 'string') throw new Error('Champion role needed');
if (role != 'pass' | !role || typeof(role) !== 'string') {
throw new Error('Champion role needed');
}

if (typeof(options) === 'function') {
cb = options;
options = {};
}

options = _.extend({
page: 1,
limit: 10
}, options);

return {
role: role,
options: options,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "node-gg",
"version": "1.0.0",
"version": "1.1.0",
"description": "Node wrapper for champion.gg API",
"main": "index.js",
"directories": {
Expand Down

0 comments on commit 138a145

Please sign in to comment.