utility method for retrieving subscription unread count

This commit is contained in:
Athou
2013-05-12 16:09:28 +02:00
parent ba46399069
commit 73154be1db
2 changed files with 59 additions and 0 deletions

View File

@@ -33,6 +33,7 @@ import com.commafeed.frontend.model.Category;
import com.commafeed.frontend.model.Entries;
import com.commafeed.frontend.model.Entry;
import com.commafeed.frontend.model.Subscription;
import com.commafeed.frontend.model.UnreadCount;
import com.commafeed.frontend.model.request.AddCategoryRequest;
import com.commafeed.frontend.model.request.CategoryModificationRequest;
import com.commafeed.frontend.model.request.CollapseRequest;
@@ -291,6 +292,19 @@ public class CategoryREST extends AbstractResourceREST {
return root;
}
@GET
@Path("unreadCount")
@ApiOperation(value = "Get unread count for feed subscriptions")
public List<UnreadCount> getUnreadCount() {
List<UnreadCount> list = Lists.newArrayList();
Map<Long, Long> unreadCount = feedEntryStatusDAO
.getUnreadCount(getUser());
for (Map.Entry<Long, Long> e : unreadCount.entrySet()) {
list.add(new UnreadCount(e.getKey(), e.getValue()));
}
return list;
}
private Category buildCategory(Long id, List<FeedCategory> categories,
List<FeedSubscription> subscriptions, Map<Long, Long> unreadCount) {
Category category = new Category();