forked from Archives/Athou_commafeed
ability to queue a feed for refresh
This commit is contained in:
@@ -14,7 +14,7 @@ import com.commafeed.backend.StartupBean;
|
|||||||
import com.commafeed.backend.dao.FeedDAO;
|
import com.commafeed.backend.dao.FeedDAO;
|
||||||
import com.commafeed.backend.model.Feed;
|
import com.commafeed.backend.model.Feed;
|
||||||
import com.commafeed.backend.services.ApplicationSettingsService;
|
import com.commafeed.backend.services.ApplicationSettingsService;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Queues;
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public class FeedRefreshTaskGiver {
|
public class FeedRefreshTaskGiver {
|
||||||
@@ -28,7 +28,14 @@ public class FeedRefreshTaskGiver {
|
|||||||
@Inject
|
@Inject
|
||||||
StartupBean startupBean;
|
StartupBean startupBean;
|
||||||
|
|
||||||
private Queue<Feed> queue = Lists.newLinkedList();
|
private Queue<Feed> queue = Queues.newConcurrentLinkedQueue();
|
||||||
|
|
||||||
|
@Lock(LockType.WRITE)
|
||||||
|
public void add(Feed feed) {
|
||||||
|
queue.add(feed);
|
||||||
|
feed.setLastUpdated(Calendar.getInstance().getTime());
|
||||||
|
feedDAO.update(feed);
|
||||||
|
}
|
||||||
|
|
||||||
@Lock(LockType.WRITE)
|
@Lock(LockType.WRITE)
|
||||||
public Feed take() {
|
public Feed take() {
|
||||||
|
|||||||
@@ -42,63 +42,66 @@ module.factory('SubscriptionService', function($resource, $http) {
|
|||||||
fetch : {
|
fetch : {
|
||||||
method : 'GET',
|
method : 'GET',
|
||||||
params : {
|
params : {
|
||||||
_method : 'feed/fetch'
|
_type : 'feed',
|
||||||
}
|
_method : 'fetch'
|
||||||
},
|
|
||||||
get : {
|
|
||||||
method : 'GET',
|
|
||||||
params : {
|
|
||||||
_method : 'get'
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
subscribe : {
|
subscribe : {
|
||||||
method : 'POST',
|
method : 'POST',
|
||||||
params : {
|
params : {
|
||||||
_method : 'feed/subscribe'
|
_type : 'feed',
|
||||||
|
_method : 'subscribe'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
unsubscribe : {
|
unsubscribe : {
|
||||||
method : 'GET',
|
method : 'GET',
|
||||||
params : {
|
params : {
|
||||||
_method : 'feed/unsubscribe'
|
_type : 'feed',
|
||||||
|
_method : 'unsubscribe'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
rename : {
|
rename : {
|
||||||
method : 'GET',
|
method : 'GET',
|
||||||
params : {
|
params : {
|
||||||
_method : 'feed/rename'
|
_type : 'feed',
|
||||||
|
_method : 'rename'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
collapse : {
|
collapse : {
|
||||||
method : 'GET',
|
method : 'GET',
|
||||||
params : {
|
params : {
|
||||||
_method : 'category/collapse'
|
_type : 'category',
|
||||||
|
_method : 'collapse'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
addCategory : {
|
addCategory : {
|
||||||
method : 'GET',
|
method : 'GET',
|
||||||
params : {
|
params : {
|
||||||
_method : 'category/add'
|
_type : 'category',
|
||||||
|
_method : 'add'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
deleteCategory : {
|
deleteCategory : {
|
||||||
method : 'GET',
|
method : 'GET',
|
||||||
params : {
|
params : {
|
||||||
_method : 'category/delete'
|
_type : 'category',
|
||||||
|
_method : 'delete'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
renameCategory : {
|
renameCategory : {
|
||||||
method : 'GET',
|
method : 'GET',
|
||||||
params : {
|
params : {
|
||||||
_method : 'category/rename'
|
_type : 'category',
|
||||||
|
_method : 'rename'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
var s = {};
|
var s = {};
|
||||||
|
s.get = $resource('rest/subscriptions/get').get;
|
||||||
s.subscriptions = {};
|
s.subscriptions = {};
|
||||||
s.flatCategories = {};
|
s.flatCategories = {};
|
||||||
|
|
||||||
var res = $resource('rest/subscriptions/:_method', {}, actions);
|
var res = $resource('rest/subscriptions/:_type/:_method', {}, actions);
|
||||||
s.init = function(callback) {
|
s.init = function(callback) {
|
||||||
res.get(function(data) {
|
res.get(function(data) {
|
||||||
s.subscriptions = data;
|
s.subscriptions = data;
|
||||||
|
|||||||
Reference in New Issue
Block a user