mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
fix unread count
This commit is contained in:
@@ -52,8 +52,15 @@ public class StartupBean {
|
||||
salt));
|
||||
userService.save(user);
|
||||
|
||||
Feed feed = new Feed("http://feed.dilbert.com/dilbert/daily_strip");
|
||||
feedService.save(feed);
|
||||
Feed dilbert = new Feed(
|
||||
"http://feed.dilbert.com/dilbert/daily_strip");
|
||||
feedService.save(dilbert);
|
||||
|
||||
Feed engadget = new Feed("http://www.engadget.com/rss.xml");
|
||||
feedService.save(engadget);
|
||||
|
||||
Feed frandroid = new Feed("http://feeds.feedburner.com/frandroid");
|
||||
feedService.save(frandroid);
|
||||
|
||||
FeedCategory newsCategory = new FeedCategory();
|
||||
newsCategory.setName("News");
|
||||
@@ -66,13 +73,32 @@ public class StartupBean {
|
||||
comicsCategory.setParent(newsCategory);
|
||||
feedCategoryService.save(comicsCategory);
|
||||
|
||||
FeedCategory techCategory = new FeedCategory();
|
||||
techCategory.setName("Tech");
|
||||
techCategory.setUser(user);
|
||||
techCategory.setParent(newsCategory);
|
||||
feedCategoryService.save(techCategory);
|
||||
|
||||
FeedSubscription sub = new FeedSubscription();
|
||||
sub.setCategory(comicsCategory);
|
||||
sub.setFeed(feed);
|
||||
sub.setFeed(dilbert);
|
||||
sub.setTitle("Dilbert - Strips");
|
||||
sub.setUser(user);
|
||||
feedSubscriptionService.save(sub);
|
||||
|
||||
FeedSubscription sub2 = new FeedSubscription();
|
||||
sub2.setCategory(techCategory);
|
||||
sub2.setFeed(engadget);
|
||||
sub2.setTitle("Engadget");
|
||||
sub2.setUser(user);
|
||||
feedSubscriptionService.save(sub2);
|
||||
|
||||
FeedSubscription sub3 = new FeedSubscription();
|
||||
sub3.setFeed(frandroid);
|
||||
sub3.setTitle("Frandroid");
|
||||
sub3.setUser(user);
|
||||
feedSubscriptionService.save(sub3);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ public class FeedEntryService extends GenericDAO<FeedEntry, String> {
|
||||
}
|
||||
|
||||
public List<FeedEntry> getUnreadEntries(Feed feed, User user) {
|
||||
String query = "select entry from FeedEntry entry where entry.feed = :feed and not in (select status.entry from FeedEntryStatus status where status.user = :user and status.read = true)";
|
||||
String query = "select e from FeedEntry e where e.feed=:feed and not exists (select s from FeedEntryStatus s where s.entry = e and s.user =:user and s.read = true)";
|
||||
TypedQuery<FeedEntry> typedQuery = em.createQuery(query,
|
||||
FeedEntry.class);
|
||||
typedQuery.setParameter("feed", feed);
|
||||
|
||||
@@ -8,6 +8,8 @@ import com.commafeed.frontend.utils.ModelFactory.MF;
|
||||
import com.commafeed.model.FeedCategory;
|
||||
import com.commafeed.model.FeedSubscription;
|
||||
import com.commafeed.model.User;
|
||||
import com.uaihebert.factory.EasyCriteriaFactory;
|
||||
import com.uaihebert.model.EasyCriteria;
|
||||
|
||||
@Stateless
|
||||
public class FeedSubscriptionService extends GenericDAO<FeedSubscription, Long> {
|
||||
@@ -15,4 +17,12 @@ public class FeedSubscriptionService extends GenericDAO<FeedSubscription, Long>
|
||||
public List<FeedSubscription> findAll(User user) {
|
||||
return findByField(MF.i(MF.p(FeedCategory.class).getUser()), user);
|
||||
}
|
||||
|
||||
public List<FeedSubscription> findWithoutCategories(User user) {
|
||||
EasyCriteria<FeedSubscription> criteria = EasyCriteriaFactory.createQueryCriteria(em, getType());
|
||||
criteria.andEquals("user", user);
|
||||
criteria.andEquals("category", null);
|
||||
return criteria.getResultList();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user