forked from Archives/Athou_commafeed
we don't need the user we already have the subscription
This commit is contained in:
@@ -201,17 +201,15 @@ public class FeedEntryStatusDAO extends GenericDAO<FeedEntryStatus> {
|
||||
return statuses;
|
||||
}
|
||||
|
||||
public UnreadCount getUnreadCount(User user, FeedSubscription sub) {
|
||||
public UnreadCount getUnreadCount(FeedSubscription sub) {
|
||||
JPAQuery<Tuple> query = query().select(entry.count(), entry.updated.max())
|
||||
.from(entry)
|
||||
.join(entry.feed, feed)
|
||||
.join(subscription)
|
||||
.on(subscription.feed.eq(feed).and(subscription.user.eq(user)))
|
||||
.on(subscription.feed.eq(feed).and(subscription.eq(sub)))
|
||||
.leftJoin(status)
|
||||
.on(status.entry.eq(entry).and(status.subscription.eq(subscription)))
|
||||
.where(subscription.eq(sub));
|
||||
|
||||
query.where(buildUnreadPredicate());
|
||||
.on(status.entry.eq(entry).and(status.subscription.eq(sub)))
|
||||
.where(buildUnreadPredicate());
|
||||
|
||||
Tuple tuple = query.fetchOne();
|
||||
Long count = tuple.get(entry.count());
|
||||
|
||||
@@ -119,14 +119,14 @@ public class FeedSubscriptionService {
|
||||
}
|
||||
|
||||
public Map<Long, UnreadCount> getUnreadCount(User user) {
|
||||
return feedSubscriptionDAO.findAll(user).stream().collect(Collectors.toMap(FeedSubscription::getId, s -> getUnreadCount(user, s)));
|
||||
return feedSubscriptionDAO.findAll(user).stream().collect(Collectors.toMap(FeedSubscription::getId, this::getUnreadCount));
|
||||
}
|
||||
|
||||
private UnreadCount getUnreadCount(User user, FeedSubscription sub) {
|
||||
private UnreadCount getUnreadCount(FeedSubscription sub) {
|
||||
UnreadCount count = cache.getUnreadCount(sub);
|
||||
if (count == null) {
|
||||
log.debug("unread count cache miss for {}", Models.getId(sub));
|
||||
count = feedEntryStatusDAO.getUnreadCount(user, sub);
|
||||
count = feedEntryStatusDAO.getUnreadCount(sub);
|
||||
cache.setUnreadCount(sub, count);
|
||||
}
|
||||
return count;
|
||||
|
||||
Reference in New Issue
Block a user