snoopdave commented on code in PR #226:
URL: https://github.com/apache/roller/pull/226#discussion_r4419759320
##########
app/src/main/java/org/apache/roller/weblogger/webservices/atomprotocol/EntryCollection.java:
##########
@@ -267,6 +267,8 @@ public void putEntry(AtomRequest areq, Entry entry) throws
AtomException {
CacheManager.invalidate(rollerEntry.getWebsite());
if (rollerEntry.isPublished()) {
roller.getIndexManager().addEntryReIndexOperation(rollerEntry);
+ } else {
+
roller.getIndexManager().removeEntryIndexOperation(rollerEntry);
Review Comment:
🤖Claude: fixed by adding a default `IndexManager.updateEntryIndex(entry)`
(re-index if published, else remove), used by the entry editor and AtomPub
`putEntry`. `EntryRemove` now just calls `removeEntryIndexOperation`, without
the set-to-draft trick. AtomPub `postEntry` still indexes only a published
entry, since a new entry has nothing to remove; comment and scheduled-post
paths are unchanged. `UpdateEntryIndexTest` covers both branches (33cf96052).
##########
app/src/main/java/org/apache/roller/weblogger/business/search/lucene/LuceneIndexManager.java:
##########
@@ -432,44 +432,56 @@ static SearchResultList convertHitsToEntryList(
List<WeblogEntryWrapper> results = new ArrayList<>();
- // determine offset
- int offset = pageNum * entryCount;
- if (offset >= hits.length) {
- offset = 0;
- }
-
- // determine limit
- int limit = entryCount;
- if (offset + limit > hits.length) {
- limit = hits.length - offset;
- }
-
try {
- Set<String> categories = new TreeSet<>();
- TreeSet<String> categorySet = new TreeSet<>();
Weblogger roller = WebloggerFactory.getWeblogger();
WeblogEntryManager weblogMgr = roller.getWeblogEntryManager();
- WeblogEntry entry;
- Document doc;
- String handle;
+ // The index can lag behind the entries, so page through the hits
+ // whose entry is published now (and not a future post). Only
+ // those count toward the offset and limit. Stop once the requested
+ // page is filled; if the hits run out first, an out-of-range page
+ // falls back to the first page below.
+ List<WeblogEntry> visible = new ArrayList<>();
+ List<Document> visibleDocs = new ArrayList<>();
Timestamp now = new Timestamp(new Date().getTime());
- for (int i = offset; i < offset + limit; i++) {
- doc = search.getSearcher().doc(hits[i].doc);
- handle =
doc.getField(FieldConstants.WEBSITE_HANDLE).stringValue();
- entry =
weblogMgr.getWeblogEntry(doc.getField(FieldConstants.ID).stringValue());
+ long wanted = (long) (pageNum + 1) * entryCount;
Review Comment:
🤖Claude: fixed by resetting to page 0 before the loop when `pageNum *
entryCount >= hits.length`. `SearchHitPagingTest` now expects an out-of-range
page to load 2 entries, not 20 (33cf96052).
##########
app/src/main/java/org/apache/roller/weblogger/business/search/lucene/LuceneIndexManager.java:
##########
@@ -432,44 +432,56 @@ static SearchResultList convertHitsToEntryList(
List<WeblogEntryWrapper> results = new ArrayList<>();
- // determine offset
- int offset = pageNum * entryCount;
- if (offset >= hits.length) {
- offset = 0;
- }
-
- // determine limit
- int limit = entryCount;
- if (offset + limit > hits.length) {
- limit = hits.length - offset;
- }
-
try {
- Set<String> categories = new TreeSet<>();
- TreeSet<String> categorySet = new TreeSet<>();
Weblogger roller = WebloggerFactory.getWeblogger();
WeblogEntryManager weblogMgr = roller.getWeblogEntryManager();
- WeblogEntry entry;
- Document doc;
- String handle;
+ // The index can lag behind the entries, so page through the hits
+ // whose entry is published now (and not a future post). Only
+ // those count toward the offset and limit. Stop once the requested
+ // page is filled; if the hits run out first, an out-of-range page
+ // falls back to the first page below.
+ List<WeblogEntry> visible = new ArrayList<>();
+ List<Document> visibleDocs = new ArrayList<>();
Review Comment:
🤖Claude: fixed by keeping one `List<VisibleHit>`; each holds the entry and
the handle and category read from its document (33cf96052).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]