mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
stay in indexes as long as possible
This commit is contained in:
@@ -16,7 +16,6 @@ import javax.persistence.criteria.Root;
|
|||||||
|
|
||||||
import org.apache.commons.lang3.ObjectUtils;
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
import org.hibernate.Criteria;
|
import org.hibernate.Criteria;
|
||||||
import org.hibernate.criterion.CriteriaSpecification;
|
|
||||||
import org.hibernate.criterion.Disjunction;
|
import org.hibernate.criterion.Disjunction;
|
||||||
import org.hibernate.criterion.MatchMode;
|
import org.hibernate.criterion.MatchMode;
|
||||||
import org.hibernate.criterion.Order;
|
import org.hibernate.criterion.Order;
|
||||||
@@ -200,26 +199,42 @@ public class FeedEntryStatusDAO extends GenericDAO<FeedEntryStatus> {
|
|||||||
for (FeedSubscription sub : subscriptions) {
|
for (FeedSubscription sub : subscriptions) {
|
||||||
Date last = (order != null && set.isFull()) ? set.last().getEntryUpdated() : null;
|
Date last = (order != null && set.isFull()) ? set.last().getEntryUpdated() : null;
|
||||||
Criteria criteria = buildSearchCriteria(sub, unreadOnly, keywords, newerThan, -1, capacity, order, includeContent, last);
|
Criteria criteria = buildSearchCriteria(sub, unreadOnly, keywords, newerThan, -1, capacity, order, includeContent, last);
|
||||||
criteria.setResultTransformer(CriteriaSpecification.ALIAS_TO_ENTITY_MAP);
|
ProjectionList projection = Projections.projectionList();
|
||||||
|
projection.add(Projections.property("id"), "id");
|
||||||
|
projection.add(Projections.property("updated"), "updated");
|
||||||
|
criteria.setProjection(projection);
|
||||||
|
criteria.setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);
|
||||||
List<Map<String, Object>> list = criteria.list();
|
List<Map<String, Object>> list = criteria.list();
|
||||||
for (Map<String, Object> map : list) {
|
for (Map<String, Object> map : list) {
|
||||||
FeedEntryStatus status = (FeedEntryStatus) map.get(ALIAS_STATUS);
|
Long id = (Long) map.get("id");
|
||||||
FeedEntry entry = (FeedEntry) map.get(ALIAS_ENTRY);
|
Date updated = (Date) map.get("updated");
|
||||||
|
|
||||||
status = handleStatus(status, sub, entry);
|
FeedEntry entry = new FeedEntry();
|
||||||
|
entry.setId(id);
|
||||||
|
entry.setUpdated(updated);
|
||||||
|
|
||||||
|
FeedEntryStatus status = new FeedEntryStatus();
|
||||||
|
status.setEntryUpdated(updated);
|
||||||
status.setEntry(entry);
|
status.setEntry(entry);
|
||||||
|
status.setSubscription(sub);
|
||||||
|
|
||||||
set.add(status);
|
set.add(status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<FeedEntryStatus> statuses = set.asList();
|
List<FeedEntryStatus> statusPlaceholders = set.asList();
|
||||||
int size = statuses.size();
|
int size = statusPlaceholders.size();
|
||||||
if (size < offset) {
|
if (size < offset) {
|
||||||
return Lists.newArrayList();
|
return Lists.newArrayList();
|
||||||
}
|
}
|
||||||
|
|
||||||
statuses = statuses.subList(Math.max(offset, 0), size);
|
statusPlaceholders = statusPlaceholders.subList(Math.max(offset, 0), size);
|
||||||
|
|
||||||
|
List<FeedEntryStatus> statuses = Lists.newArrayList();
|
||||||
|
for (FeedEntryStatus status : statusPlaceholders) {
|
||||||
|
FeedEntry entry = em.find(FeedEntry.class, status.getEntry().getId());
|
||||||
|
statuses.add(getStatus(status.getSubscription(), entry));
|
||||||
|
}
|
||||||
return lazyLoadContent(includeContent, statuses);
|
return lazyLoadContent(includeContent, statuses);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user