ability to queue a feed for refresh

This commit is contained in:
Athou
2013-04-16 12:36:36 +02:00
parent 3ab8abe5bd
commit 94251d2be7
2 changed files with 27 additions and 17 deletions

View File

@@ -14,7 +14,7 @@ import com.commafeed.backend.StartupBean;
import com.commafeed.backend.dao.FeedDAO;
import com.commafeed.backend.model.Feed;
import com.commafeed.backend.services.ApplicationSettingsService;
import com.google.common.collect.Lists;
import com.google.common.collect.Queues;
@Singleton
public class FeedRefreshTaskGiver {
@@ -28,7 +28,14 @@ public class FeedRefreshTaskGiver {
@Inject
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)
public Feed take() {

View File

@@ -42,63 +42,66 @@ module.factory('SubscriptionService', function($resource, $http) {
fetch : {
method : 'GET',
params : {
_method : 'feed/fetch'
}
},
get : {
method : 'GET',
params : {
_method : 'get'
_type : 'feed',
_method : 'fetch'
}
},
subscribe : {
method : 'POST',
params : {
_method : 'feed/subscribe'
_type : 'feed',
_method : 'subscribe'
}
},
unsubscribe : {
method : 'GET',
params : {
_method : 'feed/unsubscribe'
_type : 'feed',
_method : 'unsubscribe'
}
},
rename : {
method : 'GET',
params : {
_method : 'feed/rename'
_type : 'feed',
_method : 'rename'
}
},
collapse : {
method : 'GET',
params : {
_method : 'category/collapse'
_type : 'category',
_method : 'collapse'
}
},
addCategory : {
method : 'GET',
params : {
_method : 'category/add'
_type : 'category',
_method : 'add'
}
},
deleteCategory : {
method : 'GET',
params : {
_method : 'category/delete'
_type : 'category',
_method : 'delete'
}
},
renameCategory : {
method : 'GET',
params : {
_method : 'category/rename'
_type : 'category',
_method : 'rename'
}
}
};
var s = {};
s.get = $resource('rest/subscriptions/get').get;
s.subscriptions = {};
s.flatCategories = {};
var res = $resource('rest/subscriptions/:_method', {}, actions);
var res = $resource('rest/subscriptions/:_type/:_method', {}, actions);
s.init = function(callback) {
res.get(function(data) {
s.subscriptions = data;