mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
return count only (fixes #18)
This commit is contained in:
@@ -112,6 +112,14 @@ public class FeedEntryService extends GenericDAO<FeedEntry> {
|
||||
return buildList(query.getResultList());
|
||||
}
|
||||
|
||||
public Long getUnreadCount(Feed feed, User user) {
|
||||
TypedQuery<Long> query = em.createNamedQuery("Entry.unreadByFeedCount",
|
||||
Long.class);
|
||||
query.setParameter("feed", feed);
|
||||
query.setParameter("userId", user.getId());
|
||||
return query.getSingleResult();
|
||||
}
|
||||
|
||||
public List<FeedEntryWithStatus> getEntries(Feed feed, User user,
|
||||
boolean unreadOnly) {
|
||||
return getEntries(feed, user, unreadOnly, -1, -1);
|
||||
|
||||
@@ -9,7 +9,7 @@ public class Subscription implements Serializable {
|
||||
private String name;
|
||||
private String message;
|
||||
private String feedUrl;
|
||||
private int unread;
|
||||
private long unread;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
@@ -27,11 +27,11 @@ public class Subscription implements Serializable {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int getUnread() {
|
||||
public long getUnread() {
|
||||
return unread;
|
||||
}
|
||||
|
||||
public void setUnread(int unread) {
|
||||
public void setUnread(long unread) {
|
||||
this.unread = unread;
|
||||
}
|
||||
|
||||
|
||||
@@ -206,9 +206,8 @@ public class SubscriptionsREST extends AbstractREST {
|
||||
sub.setName(subscription.getTitle());
|
||||
sub.setMessage(subscription.getFeed().getMessage());
|
||||
sub.setFeedUrl(subscription.getFeed().getLink());
|
||||
// TODO use count instead of retrieving everything here
|
||||
int size = feedEntryService.getEntries(subscription.getFeed(),
|
||||
getUser(), true).size();
|
||||
long size = feedEntryService.getUnreadCount(
|
||||
subscription.getFeed(), getUser());
|
||||
sub.setUnread(size);
|
||||
category.getFeeds().add(sub);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user