Skip to content
This repository has been archived by the owner on Nov 28, 2018. It is now read-only.

Commit

Permalink
Merge pull request #51 from lwojcik/all_sum_bugfix
Browse files Browse the repository at this point in the history
removing unneeded method
  • Loading branch information
Łukasz Wójcik authored Feb 8, 2018
2 parents 1a3c3b7 + efbe9ee commit 10c7004
Showing 1 changed file with 2 additions and 22 deletions.
24 changes: 2 additions & 22 deletions api/starcraft2/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,26 +255,6 @@ const prepareSingleLadderSummary = (playerData) => {
return ladderSummaryObject;
};

const prepareAllLaddersSummary = (playerData) => {
const allLadders = [201, 206, 202, 203, 204]; // via https://us.battle.net/forums/en/sc2/topic/20749724960

const unprocessedLadderData = [];
const allLaddersData = [];
// let counter = 0;
allLadders.forEach(ladderCode =>
unprocessedLadderData
.push(playerData.map(playerDataObject => // eslint-disable-line no-confusing-arrow
playerDataObject.leagueInfo.queue_id === ladderCode ? playerDataObject : null)));

unprocessedLadderData.forEach((ladderDataObject) => {
const singleLadderSummary = prepareSingleLadderSummary(ladderDataObject);
allLaddersData.push(singleLadderSummary);
// counter += 1;
});

return allLaddersData;
};

/**
* Fetches StarCraft 2 player ladder data including MMR.
* @function
Expand All @@ -295,7 +275,7 @@ const getPlayerMMR = async (mode, filter, player) => {
await extractLadderObjectsByIds(server, uniqueFilteredLadderIds);
const extractedPlayerData = await extractPlayerObjectsFromLadders(extractedLadderObjects, id);
const data = (filter.toUpperCase() === 'SUM') ?
await prepareAllLaddersSummary(extractedPlayerData) :
await prepareSingleLadderSummary(extractedPlayerData) :
await filterPlayerObjectsByFilterType(extractedPlayerData, filter);
return data;
} catch (error) {
Expand All @@ -310,7 +290,7 @@ const getPlayerMMR = async (mode, filter, player) => {
* @param {Object} player - Player object including server, id, region and name.
* @returns {Promise} Promise object representing player data including MMR.
*/
const getPlayerAllLaddersSummary = async (mode, player) => { // eslint-disable-line arrow-body-style
const getPlayerAllLaddersSummary = async (player) => { // eslint-disable-line arrow-body-style
return {
'1v1': await getPlayerMMR('1v1', 'SUM', player),
archon: await getPlayerMMR('archon', 'SUM', player),
Expand Down

0 comments on commit 10c7004

Please sign in to comment.