Skip to content

Commit

Permalink
subquery for retrieving feeds to refresh was not connected to main query
Browse files Browse the repository at this point in the history
  • Loading branch information
Athou committed Jan 30, 2021
1 parent caba43b commit 015a60f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/main/java/com/commafeed/backend/dao/FeedDAO.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
@Singleton
public class FeedDAO extends GenericDAO<Feed> {

private QFeed feed = QFeed.feed;
private final QFeed feed = QFeed.feed;

@Inject
public FeedDAO(SessionFactory sessionFactory) {
Expand All @@ -36,9 +36,7 @@ public List<Feed> findNextUpdatable(int count, Date lastLoginThreshold) {
QFeedSubscription subs = QFeedSubscription.feedSubscription;
QUser user = QUser.user;

JPQLQuery<Integer> subQuery = JPAExpressions.selectOne().from(subs);
subQuery.join(subs.user, user).where(user.lastLogin.gt(lastLoginThreshold));
query.where(subQuery.exists());
query.join(feed.subscriptions, subs).join(subs.user, user).where(user.lastLogin.gt(lastLoginThreshold));
}

return query.orderBy(feed.disabledUntil.asc()).limit(count).distinct().fetch();
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/commafeed/backend/model/Feed.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.commafeed.backend.model;

import java.util.Date;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
Expand Down Expand Up @@ -121,4 +123,7 @@ public class Feed extends AbstractModel {
@Temporal(TemporalType.TIMESTAMP)
private Date pushLastPing;

@OneToMany(mappedBy = "feed")
private Set<FeedSubscription> subscriptions;

}

0 comments on commit 015a60f

Please sign in to comment.