mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
utility method for retrieving subscription unread count
This commit is contained in:
45
src/main/java/com/commafeed/frontend/model/UnreadCount.java
Normal file
45
src/main/java/com/commafeed/frontend/model/UnreadCount.java
Normal file
@@ -0,0 +1,45 @@
|
||||
package com.commafeed.frontend.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import com.wordnik.swagger.annotations.ApiClass;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
@XmlRootElement
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@ApiClass("Unread count")
|
||||
public class UnreadCount implements Serializable {
|
||||
|
||||
private long feedId;
|
||||
private long unreadCount;
|
||||
|
||||
public UnreadCount() {
|
||||
|
||||
}
|
||||
|
||||
public UnreadCount(long feedId, long unreadCount) {
|
||||
this.feedId = feedId;
|
||||
this.unreadCount = unreadCount;
|
||||
}
|
||||
|
||||
public long getFeedId() {
|
||||
return feedId;
|
||||
}
|
||||
|
||||
public void setFeedId(long feedId) {
|
||||
this.feedId = feedId;
|
||||
}
|
||||
|
||||
public long getUnreadCount() {
|
||||
return unreadCount;
|
||||
}
|
||||
|
||||
public void setUnreadCount(long unreadCount) {
|
||||
this.unreadCount = unreadCount;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user