Skip to content

Commit

Permalink
Remove redundant GAMES in queue enums
Browse files Browse the repository at this point in the history
  • Loading branch information
MingweiSamuel committed Jul 23, 2020
1 parent 025b8c9 commit 226b6ea
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,17 +186,18 @@ async function writeEnums() {
enumb['x-name'] = enumb.season.replace(/\s+/g, '_');
}),
getEnumData("http://static.developer.riotgames.com/docs/lol/queues.json", 'queueId', enums => {
const noGames = s => s.replace(/\s+GAMES$/i, '');
const groups = {};
for (const enumb of enums) {
const { map, description } = enumb;
const groupName = (map || '').replace(/'/g, '').replace(/\W+/g, '_').toUpperCase() +
(description ? '_' + description.replace(/\s+(?=\d)/g, '').replace(/\W+/g, '_').toUpperCase() : '');
const groupName = noGames(map).replace(/'/g, '').replace(/\W+/g, '_').toUpperCase() +
(description ? '_' + noGames(description).replace(/\W+/g, '_').toUpperCase() : '');
(groups[groupName] || (groups[groupName] = [])).push(enumb);
};
for (const [ groupName, groupEnums ] of Object.entries(groups)) {
for (const enumb of groupEnums) {
const { queueId, map, description, notes } = enumb;
const desc = (description ? description + ' games on ' : '') + map;
const desc = (description ? noGames(description) + ' games on ' : 'Games on ') + map;
const deprecated = !!(notes && notes.toUpperCase().includes('DEPRECATED'));
const name = groupName + ((groupEnums.length > 1 && deprecated) ? `_DEPRECATED_${queueId}` : '');

Expand Down

0 comments on commit 226b6ea

Please sign in to comment.