Browse Source

Minor performance improvements.

pull/11/head
jrtechs 5 years ago
parent
commit
34c9e1c11f
4 changed files with 26 additions and 29 deletions
  1. +16
    -5
      public/js/friendsGraph.js
  2. +7
    -9
      public/js/githubAPI.js
  3. +2
    -14
      public/js/profileGen.js
  4. +1
    -1
      routes/api.js

+ 16
- 5
public/js/friendsGraph.js View File

@ -186,15 +186,25 @@ function processUserConnections(user)
{ {
return new Promise(function(resolve, reject) 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(); updateProgress();
resolve(); resolve();
}) })
})
}
}); });
} }
@ -244,7 +254,7 @@ function updateProgress()
console.log(); console.log();
} }
var baseID;
/** /**
* Adds the base person to the graph. * Adds the base person to the graph.
* *
@ -257,6 +267,7 @@ function addSelfToGraph(username)
{ {
queryAPIByUser("", username, function(data) queryAPIByUser("", username, function(data)
{ {
baseID = data.id;
total = (data.followers + data.following); total = (data.followers + data.following);
addPersonToGraph(data); addPersonToGraph(data);
resolve(); resolve();

+ 7
- 9
public/js/githubAPI.js View File

@ -42,7 +42,6 @@ function queryAPIByUser(apiPath, user, successCallBack, errorCallBack) {
$.ajax({ $.ajax({
type:'GET', type:'GET',
url: urlpath, url: urlpath,
crossDomain: true,
dataType: "json", dataType: "json",
success: successCallBack, success: successCallBack,
error:errorCallBack, error:errorCallBack,
@ -52,27 +51,26 @@ function queryAPIByUser(apiPath, user, successCallBack, errorCallBack) {
function queryAPIByOrg(apiPath, org, successCallBack, errorCallBack) { function queryAPIByOrg(apiPath, org, successCallBack, errorCallBack) {
const urlpath = APIROOT + API_ORG_PATH + org + apiPath; const urlpath = APIROOT + API_ORG_PATH + org + apiPath;
console.log(urlpath);
$.ajax({ $.ajax({
type:'GET', type:'GET',
url: urlpath, url: urlpath,
crossDomain: true,
dataType: "json", dataType: "json",
success: successCallBack, success: successCallBack,
error:errorCallBack, error:errorCallBack,
timeout: 4000 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({ $.ajax({
type:'GET', type:'GET',
url: urlpath,
url: url,
crossDomain: true, crossDomain: true,
dataType: "json", dataType: "json",
success: successCallBack, success: successCallBack,
error:errorCallBack, error:errorCallBack,
timeout: 4000
timeout: 3000
}); });
}*/
}

+ 2
- 14
public/js/profileGen.js View File

@ -64,7 +64,8 @@ function profileGen(username, container)
</div>"; </div>";
$("#"+container).html(html); $("#"+container).html(html);
}) })
}, () => {
}, () =>
{
alert("User Does Not Exist"); alert("User Does Not Exist");
window.location.href = "./GraphGenerator.html"; 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) { function graphUrl(user) {
return "/FriendsGraph.html?name="+user; return "/FriendsGraph.html?name="+user;
} }

+ 1
- 1
routes/api.js View File

@ -91,7 +91,7 @@ routes.get('/*', (request, result) =>
result.end(); result.end();
}); });
if(cache.size() > 500000)
if(cache.size() > 50000)
{ {
cache.clear(); cache.clear();
} }

Loading…
Cancel
Save