Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

actually store the last synclet state and use it when starting again,…

… efficiency ftw
  • Loading branch information...
commit 5c984138269d8c88bdc5350696749012e80622ca 1 parent 0f92399
@quartzjer quartzjer authored
View
4 Connectors/Facebook/home.js
@@ -16,10 +16,10 @@ var fb = require('./lib.js')
exports.sync = function(processInfo, cb) {
fb.init(processInfo.auth);
var arg = {id:"me",type:"home"};
+ var since=0;
if (processInfo.config && processInfo.config.updateState && processInfo.config.updateState.home) {
- arg.since = processInfo.config.updateState.home.since;
+ since = arg.since = processInfo.config.updateState.home.since;
}
- var since=0;
fb.getPosts(arg,function(post){
posts.push({'obj' : post, timestamp: new Date(), type : 'new'});
if(post.updated_time > since) since = post.updated_time;
View
12 Connectors/Twitter/mentions.js
@@ -12,12 +12,20 @@ var tw = require('../../Connectors/Twitter/lib.js');
exports.sync = function(processInfo, cb) {
tw.init(processInfo.auth);
var me;
- var responseObj = {data : {}};
+ var responseObj = {data : {}, config:{}};
+ var since=1;
+ if (processInfo.config && processInfo.config.updateState && processInfo.config.updateState.mentions) {
+ since = processInfo.config.updateState.mentions.since;
+ }
tw.getMe({},function(js){me=js}, function(err){
if(err) return cb(err, responseObj);
var statuses = [];
- tw.getTimeline({screen_name:me.screen_name},function(js){ statuses.push({'obj' : js, timestamp: new Date(), type : 'new'}) },function(err){
+ tw.getMentions({screen_name:me.screen_name,since_id:since},function(js){
+ statuses.push({'obj' : js, timestamp: new Date(), type : 'new'});
+ if(js.id > since) since = js.id;
+ },function(err){
responseObj.data.mentions = statuses;
+ responseObj.config.updateState = {mentions:{since:since}};
cb(err, responseObj);
});
});
View
12 Connectors/Twitter/timeline.js
@@ -12,12 +12,20 @@ var tw = require('../../Connectors/Twitter/lib.js');
exports.sync = function(processInfo, cb) {
tw.init(processInfo.auth);
var me;
- var responseObj = {data : {}};
+ var responseObj = {data : {}, config:{}};
+ var since=1;
+ if (processInfo.config && processInfo.config.updateState && processInfo.config.updateState.timeline) {
+ since = processInfo.config.updateState.timeline.since;
+ }
tw.getMe({},function(js){me=js}, function(err){
if(err) return cb(err, responseObj);
var statuses = [];
- tw.getTimeline({screen_name:me.screen_name},function(js){ statuses.push({'obj' : js, timestamp: new Date(), type : 'new'}) },function(err){
+ tw.getTimeline({screen_name:me.screen_name,since_id:since},function(js){
+ statuses.push({'obj' : js, timestamp: new Date(), type : 'new'});
+ if(js.id > since) since = js.id;
+ },function(err){
responseObj.data.timeline = statuses;
+ responseObj.config.updateState = {timeline:{since:since}};
cb(err, responseObj);
});
});
View
12 Connectors/Twitter/tweets.js
@@ -12,12 +12,20 @@ var tw = require('../../Connectors/Twitter/lib.js');
exports.sync = function(processInfo, cb) {
tw.init(processInfo.auth);
var me;
- var responseObj = {data : {}};
+ var responseObj = {data : {}, config:{}};
+ var since=1;
+ if (processInfo.config && processInfo.config.updateState && processInfo.config.updateState.tweets) {
+ since = processInfo.config.updateState.tweets.since;
+ }
tw.getMe({},function(js){me=js}, function(err){
if(err) return cb(err, responseObj);
var statuses = [];
- tw.getTweets({screen_name:me.screen_name},function(js){ statuses.push({'obj' : js, timestamp: new Date(), type : 'new'}) },function(err){
+ tw.getTweets({screen_name:me.screen_name,since_id:since},function(js){
+ statuses.push({'obj' : js, timestamp: new Date(), type : 'new'});
+ if(js.id > since) since = js.id;
+ },function(err){
responseObj.data.tweets = statuses;
+ responseObj.config.updateState = {tweets:{since:since}};
cb(err, responseObj);
});
});
Please sign in to comment.
Something went wrong with that request. Please try again.