-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Still not liking its perforamnce. Most likely will go back to redis
- Loading branch information
Showing
6 changed files
with
54 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
|
||
module.exports = save; | ||
|
||
function save(projectName, recommendation, OUTPUT_ROOT) { | ||
if (!OUTPUT_ROOT) OUTPUT_ROOT = 'out'; | ||
|
||
console.log('Saving recommendation for', projectName); | ||
var pair = projectName.split('/'); | ||
var user = pair[0]; | ||
var repo = pair[1]; | ||
var targetPath = path.join(OUTPUT_ROOT, user); | ||
var targetFile = path.join(targetPath, repo + '.json').toLowerCase(); | ||
|
||
if (!fs.existsSync(targetPath)) { | ||
fs.mkdirSync(targetPath); | ||
} | ||
|
||
fs.writeFileSync(targetFile, JSON.stringify(recommendation)); | ||
return projectName; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,26 @@ | ||
var fileName = process.argv[2]; | ||
var load = require('./lib/load-watchers.js'); | ||
load('./sortedwatchers.csv', function (u, r) { global.r = r; global.u = u; }); | ||
var fileName = process.argv[2] || './watchers.csv'; | ||
var recommend = require('./lib/recommend.js'); | ||
var save = require('./lib/save.js'); | ||
|
||
var OUTPUT_ROOT = 'out'; | ||
|
||
console.log('Loading watchers information from ' + fileName); | ||
var load = require('./lib/load-watchers.js'); | ||
load(fileName, buildRecommendations); | ||
|
||
function buildRecommendations(repos, users) { | ||
var total = repos.size; | ||
var processed = 0; | ||
repos.forEach(buildForRepository); | ||
|
||
function buildForRepository(followers, repositoryName) { | ||
processed += 1; | ||
console.log(processed + '/' + total + '. Analyzing ' + repositoryName + '...'); | ||
if (followers.size < 50) { | ||
console.log(' > Skipping ' + repositoryName + ' - too little followers'); | ||
return; | ||
} | ||
var related = recommend(repositoryName, repos, users).slice(0, 100); | ||
save(repositoryName, related, OUTPUT_ROOT); | ||
} | ||
} |