Skip to content

Commit

Permalink
Methods to download favorites timelines and match details
Browse files Browse the repository at this point in the history
  • Loading branch information
hcaseyal committed Dec 2, 2017
1 parent 7e164ae commit 201ae7b
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ let express = require('express');
let app = express();
let fs = require('fs');

const port = 8082;
const port = 8080;
let baseURL = 'https://na1.api.riotgames.com/lol/';
let apiKey = 'RGAPI-dce505ed-21a4-4809-89c8-1ccc16ac1bfb';

Expand Down Expand Up @@ -49,7 +49,9 @@ app.get('/all-match-data', function (req, res) {

app.listen(port, function () {
//TODO: remove prefetchData
//prefetchFavoritesMatchData();
//prefetchFavoritesMatchData(); // YO don't call
prefetchFavoritesTimelinesData(); // these at same time because asynchronous

//prefetchMasterLeagueMatchListData();
//prefetchTimelinesAndDetailsData();
console.log(`Server running at http://localhost:${port}/`)
Expand Down Expand Up @@ -154,8 +156,8 @@ function prefetchFavoritesMatchData() {
"Svenskeren", "HotGuySixPack", "Xmithie", "ILovePotatoChips", "xNaotox"];
*/

let summonerList = ["FlowerKitten", "Amrasarfeiniel", "Pyrolykos",
"ILovePotatoChips"];
let summonerList = ["FlowerKitten", "AmrasArFeiniel", "Pyrolykos", "Tanonev",
"PerniciousRage", "ILovePotatoChips", "xNaotox", "Hikashikun", "Meteos"];

prefetchMatchListData(summonerList);
}
Expand All @@ -173,6 +175,20 @@ function prefetchMatchListData(summonerNames) {
}
}

function prefetchFavoritesTimelinesData() {
let summonerList = ["FlowerKitten", "AmrasArFeiniel", "Pyrolykos", "Tanonev",
"PerniciousRage", "ILovePotatoChips", "xNaotox", "Hikashikun", "Meteos"];

let requestContext = {requestId: 0};
let gameIdCache = {};
readFiles("./matchlist_data/", function(filename, content) {
if (summonerList.some(name => filename.includes(name))) {
onMatchlistFileContent(filename, content, requestContext, gameIdCache);
}
},
(error) => console.log(error));
}

function fetchAndWriteMatchList(info, name, requestContext) {
let promises = [];
for (let index = 0; index < 1000; index += 100) {
Expand Down

0 comments on commit 201ae7b

Please sign in to comment.