-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcron.js
More file actions
73 lines (66 loc) · 1.93 KB
/
cron.js
File metadata and controls
73 lines (66 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
var CronJob = require('cron').CronJob;
var git = require('./lib/git');
var github = require('./lib/github');
var mongo = require('./lib/mongo');
var config = require('./config.json');
/*
* JOB: search repos for github
* Runs everyday (Sunday through Saturday)
* at 00:00:01 AM.
*/
var jobSearchRepos = new CronJob({
cronTime: '01 00 00 * * 0-6',
onTick: function() {
var id = config.github_id;
var password = config.github_password;
var params = { query: 'android in:name,description,readme'
, start: '2011-01-01'
, end: new Date().toJSON().slice(0,10)
, per_page: 100
, client: github.authClient(id, password)
, config: config
};
github.searchRepos(params, function(err) {
if (err) {
console.log('FAILED: Search Repos.');
console.log(err);
} else {
console.log('DONE: Search Repos.');
}
});
},
start: false,
timeZone: 'America/Denver'
});
jobSearchRepos.start();
/*
* JOB: clone repos after filter
* Runs everyday (Sunday through Saturday)
* at 00:00:01 AM.
*/
var jobCloneRepos = new CronJob({
cronTime: '01 00 00 * * 0-6',
onTick: function() {
var params = { url: config.mongo_url
, collection: config.mongo_collection
, query: { watchers: { $gte: 5}
, size: {$lte: 40960}
, default_branch: "master"
, "private": false}
, fields: { full_name: 1, clone_url: 1, _id: 0}
};
var urlNames = {
root: config.local_repo_root,
list: []
};
mongo.find(params, function(err, items) {
console.log('=== Starting clone repos for ' + items.length
+ ' items');
urlNames.list = items;
git.multipleClone(urlNames);
});
},
start: false,
timeZone: 'America/Denver'
});
jobCloneRepos.start();