Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #16 from everzet/feature/assets

Feature/assets
  • Loading branch information...
commit 39e37fc21499979a66d36a18f675b3ffe1369bba 2 parents d34c7f8 + 2f22299
@avalanche123 avalanche123 authored
Showing with 22 additions and 32 deletions.
  1. +5 −5 lib/links_parser.js
  2. +17 −27 scripts/poller.js
View
10 lib/links_parser.js
@@ -15,11 +15,11 @@ Parser.prototype.parse = function(text, callback) {
var urls = text.split(" ").filter(function(word) {
return self.pattern.test(word);
}).map(function(url) {
- resolve(url, function(e, url) {
- api.oembed({ url: url })
- .on('complete', function(objs) {
- callback(objs[0]);
- }).start();
+ resolve(url, function(e, resolved) {
+ api.oembed({ url: resolved })
+ .on('complete', function(objs) {
+ callback(objs[0]);
+ }).start();
});
});
}
View
44 scripts/poller.js
@@ -56,7 +56,6 @@ function processEvent(job, collection, event, eventsCollection) {
poll.on('data', function(res) {
if (typeof res.results !== "undefined") {
- console.log(res);
res.results.forEach(function(json) {
var tweet = {
tweetId : json.id_str
@@ -77,9 +76,7 @@ function processEvent(job, collection, event, eventsCollection) {
})
};
- // don't process existing tweet
if (event.tweets.map(mapper('tweetId')).indexOf(tweet.tweetId) !== -1) {
- console.log('tweet exists');
return;
}
@@ -92,29 +89,26 @@ function processEvent(job, collection, event, eventsCollection) {
eventsCollection.save(event);
var relevantTalks = [];
-
- event.talks.forEach(function(talk) {
- if (talk.tweets.map(mapper('tweetId')).indexOf(tweet.tweetId) !== -1 ||
- tweet.hashes.indexOf(talk.hash) === -1) {
- eventsCollection.save(event);
- return;
- }
-
- if (talk.participants.indexOf(tweet.user) === -1) {
- talk.participants.push(tweet.user);
- }
-
- talk.tweets.push(tweet);
-
- eventsCollection.save(event);
-
- relevantTalks.push(talk);
- });
-
+// event.talks.forEach(function(talk) {
+// if (talk.tweets.map(mapper('tweetId')).indexOf(tweet.tweetId) !== -1 ||
+// tweet.hashes.indexOf(talk.hash) === -1) {
+// console.log('tweet exists in the talk');
+// return;
+// }
+//
+// if (talk.participants.indexOf(tweet.user) === -1) {
+// talk.participants.push(tweet.user);
+// }
+//
+// talk.tweets.push(tweet);
+//
+// eventsCollection.save(event);
+//
+// relevantTalks.push(talk);
+// });
links.parse(tweet.tweet, function(media) {
if (media.type === "error" ||
event.assets.map(mapper('url')).indexOf(media.url) !== -1) {
- eventsCollection.save(event);
return;
}
@@ -165,7 +159,6 @@ function createJob(callback) {
lastCreatedAt = ((lastJob || {}).createdAt || new Date(0));
- console.log(lastCreatedAt);
var cursor = collection.find({status: 'new', 'createdAt': {'$gte': lastCreatedAt}}, {tailable: true, timeout: false});
@@ -174,13 +167,10 @@ function createJob(callback) {
throw err;
}
- console.log(job);
job.status = 'run';
collection.save(job);
- console.log(job);
-
callback(job, collection);
});
});
Please sign in to comment.
Something went wrong with that request. Please try again.