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;
|
return statuses;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UnreadCount getUnreadCount(User user, FeedSubscription sub) {
|
public UnreadCount getUnreadCount(FeedSubscription sub) {
|
||||||
JPAQuery<Tuple> query = query().select(entry.count(), entry.updated.max())
|
JPAQuery<Tuple> query = query().select(entry.count(), entry.updated.max())
|
||||||
.from(entry)
|
.from(entry)
|
||||||
.join(entry.feed, feed)
|
.join(entry.feed, feed)
|
||||||
.join(subscription)
|
.join(subscription)
|
||||||
.on(subscription.feed.eq(feed).and(subscription.user.eq(user)))
|
.on(subscription.feed.eq(feed).and(subscription.eq(sub)))
|
||||||
.leftJoin(status)
|
.leftJoin(status)
|
||||||
.on(status.entry.eq(entry).and(status.subscription.eq(subscription)))
|
.on(status.entry.eq(entry).and(status.subscription.eq(sub)))
|
||||||
.where(subscription.eq(sub));
|
.where(buildUnreadPredicate());
|
||||||
|
|
||||||
query.where(buildUnreadPredicate());
|
|
||||||
|
|
||||||
Tuple tuple = query.fetchOne();
|
Tuple tuple = query.fetchOne();
|
||||||
Long count = tuple.get(entry.count());
|
Long count = tuple.get(entry.count());
|
||||||
|
|||||||
@@ -119,14 +119,14 @@ public class FeedSubscriptionService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Map<Long, UnreadCount> getUnreadCount(User user) {
|
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);
|
UnreadCount count = cache.getUnreadCount(sub);
|
||||||
if (count == null) {
|
if (count == null) {
|
||||||
log.debug("unread count cache miss for {}", Models.getId(sub));
|
log.debug("unread count cache miss for {}", Models.getId(sub));
|
||||||
count = feedEntryStatusDAO.getUnreadCount(user, sub);
|
count = feedEntryStatusDAO.getUnreadCount(sub);
|
||||||
cache.setUnreadCount(sub, count);
|
cache.setUnreadCount(sub, count);
|
||||||
}
|
}
|
||||||
return count;
|
return count;
|
||||||
|
|||||||
Reference in New Issue
Block a user