From 8d1b70bd1a03ed05b0f47fb39691962eb1f7d7b9 Mon Sep 17 00:00:00 2001 From: jrtechs Date: Sun, 17 Feb 2019 07:21:38 -0500 Subject: [PATCH] Fixed how the repository list was being generated for the organizations. --- public/js/createOrgRepoGraph.js | 41 ------------------------ public/js/createOrgTable.js | 55 ++++++++++++++++++++++++--------- public/js/friendsGraph.js | 5 --- 3 files changed, 41 insertions(+), 60 deletions(-) diff --git a/public/js/createOrgRepoGraph.js b/public/js/createOrgRepoGraph.js index b5626e1..aac0b4f 100644 --- a/public/js/createOrgRepoGraph.js +++ b/public/js/createOrgRepoGraph.js @@ -43,47 +43,6 @@ function alreadyInGraph(userID) } - -/** - * Adds the followers/following of a person - * to the graph - * - * @param username - * @param apiPath - * @returns {Promise} - */ -function addRepos(orgName, apiPath, page) -{ - console.log(orgName + " page=" + page); - updateProgress(); - return new Promise(function(resolve, reject) { - queryAPIByOrg(apiPath + "?page=" + page, orgName, function(data) { - console.log(data); - console.log(data.length); - var prom = []; - for(var i = 0; i < data.length; i++) { - if(!alreadyInGraph(data[i].id)) { - prom.push(addRepoToGraph(data[i])); - } - } - Promise.all(prom).then( () => { - if(data.length === 30) { - addRepos(orgName, apiPath, page+ 1).then(function() { - resolve(); - }) - } - else { - resolve(); - } - }) - }, - function(error) { - reject(error); - }) - }); -} - - /** * Greedy function which checks to see if a edge is in the graphs * diff --git a/public/js/createOrgTable.js b/public/js/createOrgTable.js index fd3085e..321818f 100644 --- a/public/js/createOrgTable.js +++ b/public/js/createOrgTable.js @@ -9,25 +9,52 @@ function generateHtmlRow(repoData) } -function createOrgTable(orgName, tableContainer) +var repos = []; + +function fetchAllRepositories(orgName, page) { - var html = ""; + return new Promise(function(resolve, reject) + { + queryAPIByOrg(API_REPOSITORIES + "?page=" + page, orgName, + function(data) + { + repos.push(...data); - queryAPIByOrg(API_REPOSITORIES, orgName, - function(data) - { - for(var i=0; i < data.length; i++) + if (data.length === 30) + { + fetchAllRepositories(orgName, page + 1).then(function () + { + resolve(); + }) + } + else { + resolve(); + } + }, + function(error) { - html += generateHtmlRow(data[i]); - } + //console.log("Unable to load table data"); + }); + }); +} + + +function createOrgTable(orgName, tableContainer) +{ + var html = ""; - $("#" + tableContainer).html(html); - $('#dataTable').DataTable(); - }, - function(error) + fetchAllRepositories(orgName, 1).then(function() + { + for(var i=0; i < repos.length; i++) { - console.log("Unable to load table data"); - }); + html += generateHtmlRow(repos[i]); + } + $("#" + tableContainer).html(html); + $('#dataTable').DataTable(); + }).catch(function(error) + { + //console.log("Unable to create table"); + }); } \ No newline at end of file diff --git a/public/js/friendsGraph.js b/public/js/friendsGraph.js index 48552f2..32bcc63 100644 --- a/public/js/friendsGraph.js +++ b/public/js/friendsGraph.js @@ -66,14 +66,11 @@ function addPersonToGraph(profileData) */ function addFriends(username, apiPath, page) { - console.log(username + " page=" + page); updateProgress(); return new Promise(function(resolve, reject) { queryAPIByUser(apiPath + "?page=" + page, username, function(data) { - console.log(data); - console.log(data.length); for(var i = 0; i < data.length; i++) { if(!alreadyInGraph(data[i].id)) @@ -111,7 +108,6 @@ function addFriends(username, apiPath, page) */ function edgeInGraph(id1, id2) { - console.log("edge check"); for(var i = 0;i < edges.length; i++) { if(edges[i].from === id1 && edges[i].to === id2) @@ -305,7 +301,6 @@ function createFriendsGraph(username, containerName, graphsTitle) { createConnections().then(function() { - console.log("cleared div"); $("#" + progressID).html(""); var container = document.getElementById(containerName);