diff --git a/public/js/friendsGraph.js b/public/js/friendsGraph.js index 32bcc63..b5d5007 100644 --- a/public/js/friendsGraph.js +++ b/public/js/friendsGraph.js @@ -186,15 +186,25 @@ function processUserConnections(user) { return new Promise(function(resolve, reject) { - - processConnections(user, API_FOLLOWING, 1).then(function() + if(user.id === baseID) { - processConnections(user, API_FOLLOWERS, 1).then(function() + processConnections(user, API_FOLLOWING, 1).then(function() + { + processConnections(user, API_FOLLOWERS, 1).then(function() + { + updateProgress(); + resolve(); + }) + }) + } + else + { + processConnections(user, API_FOLLOWING, 1).then(function() { updateProgress(); resolve(); }) - }) + } }); } @@ -244,7 +254,7 @@ function updateProgress() console.log(); } - +var baseID; /** * Adds the base person to the graph. * @@ -257,6 +267,7 @@ function addSelfToGraph(username) { queryAPIByUser("", username, function(data) { + baseID = data.id; total = (data.followers + data.following); addPersonToGraph(data); resolve(); diff --git a/public/js/githubAPI.js b/public/js/githubAPI.js index 5e1e306..0dbe0a6 100644 --- a/public/js/githubAPI.js +++ b/public/js/githubAPI.js @@ -42,7 +42,6 @@ function queryAPIByUser(apiPath, user, successCallBack, errorCallBack) { $.ajax({ type:'GET', url: urlpath, - crossDomain: true, dataType: "json", success: successCallBack, error:errorCallBack, @@ -52,27 +51,26 @@ function queryAPIByUser(apiPath, user, successCallBack, errorCallBack) { function queryAPIByOrg(apiPath, org, successCallBack, errorCallBack) { const urlpath = APIROOT + API_ORG_PATH + org + apiPath; + console.log(urlpath); $.ajax({ type:'GET', url: urlpath, - crossDomain: true, dataType: "json", success: successCallBack, error:errorCallBack, timeout: 4000 }); - console.log("past"); } -/* -function queryAPIByRepo(apiPath, org, successCallBack, errorCallBack) { - const urlpath = APIROOT + API_ORG_PATH + org + apiPath; + +function queryUrl(url, successCallBack, errorCallBack) { + url = url.split("https://api.github.com/").join("api/"); $.ajax({ type:'GET', - url: urlpath, + url: url, crossDomain: true, dataType: "json", success: successCallBack, error:errorCallBack, - timeout: 4000 + timeout: 3000 }); -}*/ \ No newline at end of file +} \ No newline at end of file diff --git a/public/js/profileGen.js b/public/js/profileGen.js index c5267e0..0a438a8 100644 --- a/public/js/profileGen.js +++ b/public/js/profileGen.js @@ -64,7 +64,8 @@ function profileGen(username, container) "; $("#"+container).html(html); }) - }, () => { + }, () => + { alert("User Does Not Exist"); window.location.href = "./GraphGenerator.html"; }); @@ -101,19 +102,6 @@ function parseOrgs(name) { }) } -function queryUrl(url, successCallBack, errorCallBack) { - url = url.split("https://api.github.com/").join("api/"); - $.ajax({ - type:'GET', - url: url, - crossDomain: true, - dataType: "json", - success: successCallBack, - error:errorCallBack, - timeout: 3000 - }); -} - function graphUrl(user) { return "/FriendsGraph.html?name="+user; } diff --git a/routes/api.js b/routes/api.js index 1f420de..d1c038c 100644 --- a/routes/api.js +++ b/routes/api.js @@ -91,7 +91,7 @@ routes.get('/*', (request, result) => result.end(); }); - if(cache.size() > 500000) + if(cache.size() > 50000) { cache.clear(); }