mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
refactored the way entries and statuses are fetched
This commit is contained in:
@@ -12,8 +12,10 @@ import org.apache.wicket.request.mapper.parameter.PageParameters;
|
||||
|
||||
import com.commafeed.backend.dao.FeedCategoryDAO;
|
||||
import com.commafeed.backend.dao.FeedEntryStatusDAO;
|
||||
import com.commafeed.backend.dao.FeedSubscriptionDAO;
|
||||
import com.commafeed.backend.model.FeedCategory;
|
||||
import com.commafeed.backend.model.FeedEntryStatus;
|
||||
import com.commafeed.backend.model.FeedSubscription;
|
||||
import com.commafeed.backend.model.User;
|
||||
import com.commafeed.backend.model.UserRole.Role;
|
||||
import com.commafeed.backend.model.UserSettings.ReadingOrder;
|
||||
@@ -35,13 +37,16 @@ public class NextUnreadRedirectPage extends WebPage {
|
||||
@Inject
|
||||
FeedEntryStatusDAO feedEntryStatusDAO;
|
||||
|
||||
@Inject
|
||||
FeedSubscriptionDAO feedSubscriptionDAO;
|
||||
|
||||
public NextUnreadRedirectPage(PageParameters params) {
|
||||
String categoryId = params.get(PARAM_CATEGORYID).toString();
|
||||
String orderParam = params.get(PARAM_READINGORDER).toString();
|
||||
|
||||
|
||||
User user = CommaFeedSession.get().getUser();
|
||||
ReadingOrder order = ReadingOrder.desc;
|
||||
|
||||
|
||||
if (StringUtils.equals(orderParam, "asc")) {
|
||||
order = ReadingOrder.asc;
|
||||
}
|
||||
@@ -49,16 +54,20 @@ public class NextUnreadRedirectPage extends WebPage {
|
||||
List<FeedEntryStatus> statuses = null;
|
||||
if (StringUtils.isBlank(categoryId)
|
||||
|| CategoryREST.ALL.equals(categoryId)) {
|
||||
statuses = feedEntryStatusDAO.findAllUnread(user, null, 0, 1,
|
||||
order, true);
|
||||
List<FeedSubscription> subscriptions = feedSubscriptionDAO
|
||||
.findAll(user);
|
||||
statuses = feedEntryStatusDAO.findBySubscriptions(subscriptions,
|
||||
null, null, 0, 1, order, true);
|
||||
} else {
|
||||
FeedCategory category = feedCategoryDAO.findById(user,
|
||||
Long.valueOf(categoryId));
|
||||
if (category != null) {
|
||||
List<FeedCategory> children = feedCategoryDAO
|
||||
.findAllChildrenCategories(user, category);
|
||||
statuses = feedEntryStatusDAO.findUnreadByCategories(children,
|
||||
null, 0, 1, order, true);
|
||||
List<FeedSubscription> subscriptions = feedSubscriptionDAO
|
||||
.findByCategories(user, children);
|
||||
statuses = feedEntryStatusDAO.findUnreadBySubscriptions(
|
||||
subscriptions, null, 0, 1, order, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user