Skip to content

Instantly share code, notes, and snippets.

@saurshaz
Last active July 31, 2016 05:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saurshaz/5cdd1d13ba85511914b983769794cbf9 to your computer and use it in GitHub Desktop.
Save saurshaz/5cdd1d13ba85511914b983769794cbf9 to your computer and use it in GitHub Desktop.
A webtask to fetch alot of people related in similar stuff. a list of all people following all people that i follow (my siblings)
var async = require('async');
var GitHubApi = require("github@0.2.4");
// module.exports = function (ctx, done) {
// var words = ctx.data.title
// .split(' ')
// .concat(
// ctx.data.excerpt.split(' ')
// );
// MongoClient.connect(ctx.data.MONGO_URL, function (err, db) {
// if(err) return done(err);
// var job_list = words.map(function (word) {
// return function (cb) {
// save_word(word, db, function (err) {
// if(err) return cb(err);
// cb(null);
// });
// };
// });
// parallel(job_list, function (err) {
// if(err) return done(err);
// done(null, 'Success.');
// });
// });
// };
module.exports = function (ctx, done) {
var users = Array();
var github = new GitHubApi({});
github.authenticate({
version:'3.0.0',
type: "oauth",
token: ctx.data.GITHUB_AUTH
});
var allStarredRepos = [];
github.activity.getStarredRepos({ per_page: 100}, function getRepos(err, res) {
if (err) {
return [];
}
allStarredRepos = allStarredRepos.concat(res);
// console.log('repo >>> ' ,allStarredRepos)
async.map(allStarredRepos,function (repo, doneOut){
github.repos.getContributors({
user: repo.owner.login,
repo: repo.name
}, function (err, contributors) {
return async.map(contributors,function (contributor, done) {
console.log("\n\n");
users.push({user:contributor.login})
done()
},function (err, res) {
doneOut()
})
})
},function (err, res) {
console.log("done information fetching .... ");
console.log("********** ")
console.log(users)
})
})
}
// launch({data:{GITHUB_AUTH:'XXXX'}})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment