Skip to content

Commit

Permalink
Merge pull request #16 from everzet/feature/assets
Browse files Browse the repository at this point in the history
Feature/assets
  • Loading branch information
avalanche123 committed Sep 7, 2011
2 parents d34c7f8 + 2f22299 commit 39e37fc
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 32 deletions.
10 changes: 5 additions & 5 deletions lib/links_parser.js
Expand Up @@ -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();
});
});
}
Expand Down
44 changes: 17 additions & 27 deletions scripts/poller.js
Expand Up @@ -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
Expand All @@ -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;
}

Expand All @@ -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;
}

Expand Down Expand Up @@ -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});

Expand All @@ -174,13 +167,10 @@ function createJob(callback) {
throw err;
}

console.log(job);
job.status = 'run';

collection.save(job);

console.log(job);

callback(job, collection);
});
});
Expand Down

0 comments on commit 39e37fc

Please sign in to comment.