mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
rename field accordingly
This commit is contained in:
@@ -50,7 +50,11 @@ public class FeedEntryDAO extends GenericDAO<FeedEntry> {
|
|||||||
* Delete entries older than a certain date
|
* Delete entries older than a certain date
|
||||||
*/
|
*/
|
||||||
public int deleteEntriesOlderThan(Instant olderThan, long max) {
|
public int deleteEntriesOlderThan(Instant olderThan, long max) {
|
||||||
List<FeedEntry> list = query().selectFrom(ENTRY).where(ENTRY.updated.lt(olderThan)).orderBy(ENTRY.updated.asc()).limit(max).fetch();
|
List<FeedEntry> list = query().selectFrom(ENTRY)
|
||||||
|
.where(ENTRY.published.lt(olderThan))
|
||||||
|
.orderBy(ENTRY.published.asc())
|
||||||
|
.limit(max)
|
||||||
|
.fetch();
|
||||||
return delete(list);
|
return delete(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,7 +62,7 @@ public class FeedEntryDAO extends GenericDAO<FeedEntry> {
|
|||||||
* Delete the oldest entries of a feed
|
* Delete the oldest entries of a feed
|
||||||
*/
|
*/
|
||||||
public int deleteOldEntries(Long feedId, long max) {
|
public int deleteOldEntries(Long feedId, long max) {
|
||||||
List<FeedEntry> list = query().selectFrom(ENTRY).where(ENTRY.feed.id.eq(feedId)).orderBy(ENTRY.updated.asc()).limit(max).fetch();
|
List<FeedEntry> list = query().selectFrom(ENTRY).where(ENTRY.feed.id.eq(feedId)).orderBy(ENTRY.published.asc()).limit(max).fetch();
|
||||||
return delete(list);
|
return delete(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ public class FeedEntryStatusDAO extends GenericDAO<FeedEntryStatus> {
|
|||||||
private FeedEntryStatus handleStatus(User user, FeedEntryStatus status, FeedSubscription sub, FeedEntry entry) {
|
private FeedEntryStatus handleStatus(User user, FeedEntryStatus status, FeedSubscription sub, FeedEntry entry) {
|
||||||
if (status == null) {
|
if (status == null) {
|
||||||
Instant unreadThreshold = config.getApplicationSettings().getUnreadThreshold();
|
Instant unreadThreshold = config.getApplicationSettings().getUnreadThreshold();
|
||||||
boolean read = unreadThreshold != null && entry.getUpdated().isBefore(unreadThreshold);
|
boolean read = unreadThreshold != null && entry.getPublished().isBefore(unreadThreshold);
|
||||||
status = new FeedEntryStatus(user, sub, entry);
|
status = new FeedEntryStatus(user, sub, entry);
|
||||||
status.setRead(read);
|
status.setRead(read);
|
||||||
status.setMarkable(!read);
|
status.setMarkable(!read);
|
||||||
@@ -92,9 +92,9 @@ public class FeedEntryStatusDAO extends GenericDAO<FeedEntryStatus> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (order == ReadingOrder.asc) {
|
if (order == ReadingOrder.asc) {
|
||||||
query.orderBy(STATUS.entryUpdated.asc(), STATUS.id.asc());
|
query.orderBy(STATUS.entryPublished.asc(), STATUS.id.asc());
|
||||||
} else {
|
} else {
|
||||||
query.orderBy(STATUS.entryUpdated.desc(), STATUS.id.desc());
|
query.orderBy(STATUS.entryPublished.desc(), STATUS.id.desc());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (offset > -1) {
|
if (offset > -1) {
|
||||||
@@ -165,9 +165,9 @@ public class FeedEntryStatusDAO extends GenericDAO<FeedEntryStatus> {
|
|||||||
|
|
||||||
if (order != null) {
|
if (order != null) {
|
||||||
if (order == ReadingOrder.asc) {
|
if (order == ReadingOrder.asc) {
|
||||||
query.orderBy(ENTRY.updated.asc(), ENTRY.id.asc());
|
query.orderBy(ENTRY.published.asc(), ENTRY.id.asc());
|
||||||
} else {
|
} else {
|
||||||
query.orderBy(ENTRY.updated.desc(), ENTRY.id.desc());
|
query.orderBy(ENTRY.published.desc(), ENTRY.id.desc());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -199,7 +199,7 @@ public class FeedEntryStatusDAO extends GenericDAO<FeedEntryStatus> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public UnreadCount getUnreadCount(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.published.max())
|
||||||
.from(ENTRY)
|
.from(ENTRY)
|
||||||
.leftJoin(ENTRY.statuses, STATUS)
|
.leftJoin(ENTRY.statuses, STATUS)
|
||||||
.on(STATUS.subscription.eq(sub))
|
.on(STATUS.subscription.eq(sub))
|
||||||
@@ -208,8 +208,8 @@ public class FeedEntryStatusDAO extends GenericDAO<FeedEntryStatus> {
|
|||||||
|
|
||||||
Tuple tuple = query.fetchOne();
|
Tuple tuple = query.fetchOne();
|
||||||
Long count = tuple.get(ENTRY.count());
|
Long count = tuple.get(ENTRY.count());
|
||||||
Instant updated = tuple.get(ENTRY.updated.max());
|
Instant published = tuple.get(ENTRY.published.max());
|
||||||
return new UnreadCount(sub.getId(), count == null ? 0 : count, updated);
|
return new UnreadCount(sub.getId(), count == null ? 0 : count, published);
|
||||||
}
|
}
|
||||||
|
|
||||||
private BooleanBuilder buildUnreadPredicate() {
|
private BooleanBuilder buildUnreadPredicate() {
|
||||||
@@ -219,7 +219,7 @@ public class FeedEntryStatusDAO extends GenericDAO<FeedEntryStatus> {
|
|||||||
|
|
||||||
Instant unreadThreshold = config.getApplicationSettings().getUnreadThreshold();
|
Instant unreadThreshold = config.getApplicationSettings().getUnreadThreshold();
|
||||||
if (unreadThreshold != null) {
|
if (unreadThreshold != null) {
|
||||||
return or.and(ENTRY.updated.goe(unreadThreshold));
|
return or.and(ENTRY.published.goe(unreadThreshold));
|
||||||
} else {
|
} else {
|
||||||
return or;
|
return or;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,10 +46,9 @@ public class FeedEntry extends AbstractModel {
|
|||||||
/**
|
/**
|
||||||
* the moment the entry was published in the feed
|
* the moment the entry was published in the feed
|
||||||
*
|
*
|
||||||
* TODO rename the field to published
|
|
||||||
*/
|
*/
|
||||||
@Column
|
@Column(name = "updated")
|
||||||
private Instant updated;
|
private Instant published;
|
||||||
|
|
||||||
@OneToMany(mappedBy = "entry", cascade = CascadeType.REMOVE)
|
@OneToMany(mappedBy = "entry", cascade = CascadeType.REMOVE)
|
||||||
private Set<FeedEntryStatus> statuses;
|
private Set<FeedEntryStatus> statuses;
|
||||||
|
|||||||
@@ -50,8 +50,8 @@ public class FeedEntryStatus extends AbstractModel {
|
|||||||
@Column
|
@Column
|
||||||
private Instant entryInserted;
|
private Instant entryInserted;
|
||||||
|
|
||||||
@Column
|
@Column(name = "entryUpdated")
|
||||||
private Instant entryUpdated;
|
private Instant entryPublished;
|
||||||
|
|
||||||
public FeedEntryStatus() {
|
public FeedEntryStatus() {
|
||||||
|
|
||||||
@@ -62,7 +62,7 @@ public class FeedEntryStatus extends AbstractModel {
|
|||||||
this.subscription = subscription;
|
this.subscription = subscription;
|
||||||
this.entry = entry;
|
this.entry = entry;
|
||||||
this.entryInserted = entry.getInserted();
|
this.entryInserted = entry.getInserted();
|
||||||
this.entryUpdated = entry.getUpdated();
|
this.entryPublished = entry.getPublished();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ public class FeedEntryService {
|
|||||||
feedEntry.setGuid(FeedUtils.truncate(entry.guid(), 2048));
|
feedEntry.setGuid(FeedUtils.truncate(entry.guid(), 2048));
|
||||||
feedEntry.setGuidHash(Digests.sha1Hex(entry.guid()));
|
feedEntry.setGuidHash(Digests.sha1Hex(entry.guid()));
|
||||||
feedEntry.setUrl(FeedUtils.truncate(entry.url(), 2048));
|
feedEntry.setUrl(FeedUtils.truncate(entry.url(), 2048));
|
||||||
feedEntry.setUpdated(entry.published());
|
feedEntry.setPublished(entry.published());
|
||||||
feedEntry.setInserted(Instant.now());
|
feedEntry.setInserted(Instant.now());
|
||||||
feedEntry.setFeed(feed);
|
feedEntry.setFeed(feed);
|
||||||
feedEntry.setContent(feedEntryContentService.findOrCreate(entry.content(), feed.getLink()));
|
feedEntry.setContent(feedEntryContentService.findOrCreate(entry.content(), feed.getLink()));
|
||||||
@@ -124,7 +124,7 @@ public class FeedEntryService {
|
|||||||
|
|
||||||
private void markList(List<FeedEntryStatus> statuses, Instant olderThan, Instant insertedBefore) {
|
private void markList(List<FeedEntryStatus> statuses, Instant olderThan, Instant insertedBefore) {
|
||||||
List<FeedEntryStatus> statusesToMark = statuses.stream().filter(FeedEntryStatus::isMarkable).filter(s -> {
|
List<FeedEntryStatus> statusesToMark = statuses.stream().filter(FeedEntryStatus::isMarkable).filter(s -> {
|
||||||
Instant entryDate = s.getEntry().getUpdated();
|
Instant entryDate = s.getEntry().getPublished();
|
||||||
return olderThan == null || entryDate == null || entryDate.isBefore(olderThan);
|
return olderThan == null || entryDate == null || entryDate.isBefore(olderThan);
|
||||||
}).filter(s -> {
|
}).filter(s -> {
|
||||||
Instant insertedDate = s.getEntry().getInserted();
|
Instant insertedDate = s.getEntry().getInserted();
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ public class Entry implements Serializable {
|
|||||||
entry.setRead(status.isRead());
|
entry.setRead(status.isRead());
|
||||||
entry.setStarred(status.isStarred());
|
entry.setStarred(status.isStarred());
|
||||||
entry.setMarkable(status.isMarkable());
|
entry.setMarkable(status.isMarkable());
|
||||||
entry.setDate(feedEntry.getUpdated());
|
entry.setDate(feedEntry.getPublished());
|
||||||
entry.setInsertedDate(feedEntry.getInserted());
|
entry.setInsertedDate(feedEntry.getInserted());
|
||||||
entry.setUrl(feedEntry.getUrl());
|
entry.setUrl(feedEntry.getUrl());
|
||||||
entry.setFeedName(sub.getTitle());
|
entry.setFeedName(sub.getTitle());
|
||||||
|
|||||||
@@ -295,7 +295,7 @@ public class FeverREST {
|
|||||||
i.setUrl(s.getEntry().getUrl());
|
i.setUrl(s.getEntry().getUrl());
|
||||||
i.setSaved(s.isStarred());
|
i.setSaved(s.isStarred());
|
||||||
i.setRead(s.isRead());
|
i.setRead(s.isRead());
|
||||||
i.setCreatedOnTime(s.getEntryUpdated().getEpochSecond());
|
i.setCreatedOnTime(s.getEntryPublished().getEpochSecond());
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user