-
Notifications
You must be signed in to change notification settings - Fork 0
/
twelpCheck.js
61 lines (48 loc) · 1.37 KB
/
twelpCheck.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// **************************
// ****** DEPENDENCIES ******
// **************************
var _ = require('lodash');
var proc = require('./util/process');
var tm = require('./analysis/twelpMap');
var database = require('./api/database');
var twitter = require('./api/twitterApi');
// **************************
// ****** PROGRAM ******
// **************************
database.runWithConn(function() {
tm.getAllResetaurantUsers(function(users) {
users = _.filter(users, function (user) {
return user != 'dunkindonuts'
&& user != 'subway'
&& user != 'starbucks'
&& user != 'share'
&& user != 'mcdonalds'
;
});
users = _.map(users, function(user) { return '@' + user; });
console.log(users.length);
var start = new Date();
var count = 0;
twitter.startStream({track: users.join()}, function(tweet) {
if (tweet.text.indexOf('RT ') == 0) {
return;
}
var matching = _.filter(users, function(user) { return tweet.text.indexOf(user) != -1; });
if (matching.length == 0) {
return;
}
count++;
var elapsed = new Date() - start;
console.log(count + " tweets, " + elapsed/1000 + " s");
console.log("MATCHES " + matching.join());
});
});
});
return;
tm.findTweets(function(err, tweets) {
if (err) {
proc.bail('Finding tweets mentioning restaurants failed.', err);
}
console.log(tweets);
console.log(tweets.length);
});