-
Notifications
You must be signed in to change notification settings - Fork 0
/
convo.js
46 lines (35 loc) · 1.07 KB
/
convo.js
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
// **************************
// ****** DEPENDENCIES ******
// **************************
var twitter = require('./api/twitterApi');
var database = require('./api/database');
var _ = require('lodash');
var schema = require('./api/schema');
var proc = require('./util/process');
// **************************
// ******** PROGRAM ********
// **************************
database.runWithConn(function() {
database.getConvoTweets(function(err, tweets) {
if (err) {
proc.bail('Getting convo tweets failed', err);
}
console.log('CONVO TWEETS: ' + tweets.length);
if (tweets.length == 0) {
proc.done();
}
_.each(_.first(tweets, 50), function(first) {
twitter.trackConversionBack(first, 10, function(err2, convo) {
if (err2) {
proc.bail('Convo tracking failed', err2);
}
database.updateTweet(first['_id'], {conversation: convo}, function(err3, updated) {
if (err3) {
proc.bail('Saving convo failed', err3);
}
console.log('Saved convo length ' + convo.length + ' for ' + first['_id']);
});
});
});
});
});