Browse Source

Merge branch 'master' of github.com:jrtechs/github-graphs

pull/11/head
Bryce Murphy 5 years ago
parent
commit
84a5be656c
4 changed files with 25 additions and 28 deletions
  1. +0
    -6
      configManager.js
  2. +1
    -2
      public/FriendsGraph.html
  3. +2
    -2
      public/js/friendsGraph.js
  4. +22
    -18
      routes/api.js

+ 0
- 6
configManager.js View File

@ -33,11 +33,5 @@ module.exports=
getSessionSecret: function() getSessionSecret: function()
{ {
return config.sessionSecret; return config.sessionSecret;
},
getAPIUser: function()
{
return config.user;
} }
}; };

+ 1
- 2
public/FriendsGraph.html View File

@ -54,7 +54,7 @@
<div class="row"> <div class="row">
<div class="col-md-8 col-12"> <div class="col-md-8 col-12">
<h2 id="graphLabel"></h2>
<h2 id="graphLoading"></h2>
<div id="myGraph" class="w-100"></div> <div id="myGraph" class="w-100"></div>
<pre id="eventSpan"></pre> <pre id="eventSpan"></pre>
</div> </div>
@ -62,7 +62,6 @@
<div id="profileGen"></div> <div id="profileGen"></div>
</div> </div>
</div> </div>
<script> <script>
function createGraphs(username) function createGraphs(username)

+ 2
- 2
public/js/friendsGraph.js View File

@ -82,7 +82,7 @@ function addFriends(username, apiPath, page)
} }
} }
if(data.length === 30)
if(page < 50 && data.length === 30)
{ {
addFriends(username, apiPath, page+ 1).then(function() addFriends(username, apiPath, page+ 1).then(function()
{ {
@ -161,7 +161,7 @@ function processConnections(user, apiPoint, page)
{ {
addConnection(user, data[i]) addConnection(user, data[i])
} }
if(data.length === 30)
if(page < 50 && data.length === 30)
{ {
processConnections(user, apiPoint, page + 1).then(function() processConnections(user, apiPoint, page + 1).then(function()
{ {

+ 22
- 18
routes/api.js View File

@ -34,6 +34,7 @@ function queryGitHubAPI(requestURL)
{ {
queryURL = GITHUB_API + requestURL + "?" + authenticate; queryURL = GITHUB_API + requestURL + "?" + authenticate;
} }
console.log(queryURL);
got(queryURL, { json: true }).then(response => got(queryURL, { json: true }).then(response =>
{ {
@ -41,15 +42,13 @@ function queryGitHubAPI(requestURL)
cache.put(requestURL, response.body); cache.put(requestURL, response.body);
}).catch(error => }).catch(error =>
{ {
// resolve(response.body);
// cache.put(requestURL, response.body);
console.log(error);
reject(error);
resolve(error);
cache.put(requestURL, error);
}); });
} }
else else
{ {
console.log("Fetched From Cahce");
resolve(apiData); resolve(apiData);
} }
}) })
@ -60,26 +59,31 @@ routes.get('/*', (request, result) =>
{ {
var gitHubAPIURL = request.url; var gitHubAPIURL = request.url;
// if(request.query.hasOwnProperty("page"))
// {
// gitHubAPIURL += "?page=" + request.query.page;
// }
console.log(request.query);
console.log(gitHubAPIURL);
result.setHeader('Content-Type', 'application/json'); result.setHeader('Content-Type', 'application/json');
queryGitHubAPI(gitHubAPIURL).then(function(data) queryGitHubAPI(gitHubAPIURL).then(function(data)
{ {
result.write(JSON.stringify(data));
if(data.hasOwnProperty("id") || data[0].hasOwnProperty("id"))
{
result.write(JSON.stringify(data));
}
result.end(); result.end();
}).catch(function(error) }).catch(function(error)
{ {
result.write(JSON.stringify(error));
try
{
if(error.hasOwnProperty("id") || error[0].hasOwnProperty("id"))
{
result.write(JSON.stringify(error));
}
}
catch(error) {};
result.end(); result.end();
})
});
if(cache.size() > 500000)
{
cache.clear();
}
}); });
module.exports = routes; module.exports = routes;

Loading…
Cancel
Save