1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-06-27 16:36:00 +00:00

fix: improve pagination when having identical publication date

This commit is contained in:
Frédéric Guillot 2025-01-18 16:49:08 -08:00
parent 9c82e55b98
commit 400e8974f9
10 changed files with 12 additions and 3 deletions

View file

@ -112,13 +112,13 @@ func (e *EntryPaginationBuilder) getPrevNextID(tx *sql.Tx) (prevID int64, nextID
WITH entry_pagination AS ( WITH entry_pagination AS (
SELECT SELECT
e.id, e.id,
lag(e.id) over (order by e.%[1]s asc, e.id desc) as prev_id, lag(e.id) over (order by e.%[1]s asc, e.created_at asc, e.id desc) as prev_id,
lead(e.id) over (order by e.%[1]s asc, e.id desc) as next_id lead(e.id) over (order by e.%[1]s asc, e.created_at asc, e.id desc) as next_id
FROM entries AS e FROM entries AS e
JOIN feeds AS f ON f.id=e.feed_id JOIN feeds AS f ON f.id=e.feed_id
JOIN categories c ON c.id = f.category_id JOIN categories c ON c.id = f.category_id
WHERE %[2]s WHERE %[2]s
ORDER BY e.%[1]s asc, e.id desc ORDER BY e.%[1]s asc, e.created_at asc, e.id desc
) )
SELECT prev_id, next_id FROM entry_pagination AS ep WHERE %[3]s; SELECT prev_id, next_id FROM entry_pagination AS ep WHERE %[3]s;
` `

View file

@ -26,6 +26,7 @@ func (h *handler) showStarredPage(w http.ResponseWriter, r *http.Request) {
builder.WithoutStatus(model.EntryStatusRemoved) builder.WithoutStatus(model.EntryStatusRemoved)
builder.WithStarred(true) builder.WithStarred(true)
builder.WithSorting(user.EntryOrder, user.EntryDirection) builder.WithSorting(user.EntryOrder, user.EntryDirection)
builder.WithSorting("id", user.EntryDirection)
builder.WithOffset(offset) builder.WithOffset(offset)
builder.WithLimit(user.EntriesPerPage) builder.WithLimit(user.EntriesPerPage)

View file

@ -37,6 +37,7 @@ func (h *handler) showCategoryEntriesPage(w http.ResponseWriter, r *http.Request
builder := h.store.NewEntryQueryBuilder(user.ID) builder := h.store.NewEntryQueryBuilder(user.ID)
builder.WithCategoryID(category.ID) builder.WithCategoryID(category.ID)
builder.WithSorting(user.EntryOrder, user.EntryDirection) builder.WithSorting(user.EntryOrder, user.EntryDirection)
builder.WithSorting("id", user.EntryDirection)
builder.WithStatus(model.EntryStatusUnread) builder.WithStatus(model.EntryStatusUnread)
builder.WithOffset(offset) builder.WithOffset(offset)
builder.WithLimit(user.EntriesPerPage) builder.WithLimit(user.EntriesPerPage)

View file

@ -37,6 +37,7 @@ func (h *handler) showCategoryEntriesAllPage(w http.ResponseWriter, r *http.Requ
builder := h.store.NewEntryQueryBuilder(user.ID) builder := h.store.NewEntryQueryBuilder(user.ID)
builder.WithCategoryID(category.ID) builder.WithCategoryID(category.ID)
builder.WithSorting(user.EntryOrder, user.EntryDirection) builder.WithSorting(user.EntryOrder, user.EntryDirection)
builder.WithSorting("id", user.EntryDirection)
builder.WithoutStatus(model.EntryStatusRemoved) builder.WithoutStatus(model.EntryStatusRemoved)
builder.WithOffset(offset) builder.WithOffset(offset)
builder.WithLimit(user.EntriesPerPage) builder.WithLimit(user.EntriesPerPage)

View file

@ -37,6 +37,7 @@ func (h *handler) showCategoryEntriesStarredPage(w http.ResponseWriter, r *http.
builder := h.store.NewEntryQueryBuilder(user.ID) builder := h.store.NewEntryQueryBuilder(user.ID)
builder.WithCategoryID(category.ID) builder.WithCategoryID(category.ID)
builder.WithSorting(user.EntryOrder, user.EntryDirection) builder.WithSorting(user.EntryOrder, user.EntryDirection)
builder.WithSorting("id", user.EntryDirection)
builder.WithoutStatus(model.EntryStatusRemoved) builder.WithoutStatus(model.EntryStatusRemoved)
builder.WithStarred(true) builder.WithStarred(true)
builder.WithOffset(offset) builder.WithOffset(offset)

View file

@ -38,6 +38,7 @@ func (h *handler) showFeedEntriesPage(w http.ResponseWriter, r *http.Request) {
builder.WithFeedID(feed.ID) builder.WithFeedID(feed.ID)
builder.WithStatus(model.EntryStatusUnread) builder.WithStatus(model.EntryStatusUnread)
builder.WithSorting(user.EntryOrder, user.EntryDirection) builder.WithSorting(user.EntryOrder, user.EntryDirection)
builder.WithSorting("id", user.EntryDirection)
builder.WithOffset(offset) builder.WithOffset(offset)
builder.WithLimit(user.EntriesPerPage) builder.WithLimit(user.EntriesPerPage)

View file

@ -38,6 +38,7 @@ func (h *handler) showFeedEntriesAllPage(w http.ResponseWriter, r *http.Request)
builder.WithFeedID(feed.ID) builder.WithFeedID(feed.ID)
builder.WithoutStatus(model.EntryStatusRemoved) builder.WithoutStatus(model.EntryStatusRemoved)
builder.WithSorting(user.EntryOrder, user.EntryDirection) builder.WithSorting(user.EntryOrder, user.EntryDirection)
builder.WithSorting("id", user.EntryDirection)
builder.WithOffset(offset) builder.WithOffset(offset)
builder.WithLimit(user.EntriesPerPage) builder.WithLimit(user.EntriesPerPage)

View file

@ -24,6 +24,7 @@ func (h *handler) sharedEntries(w http.ResponseWriter, r *http.Request) {
builder := h.store.NewEntryQueryBuilder(user.ID) builder := h.store.NewEntryQueryBuilder(user.ID)
builder.WithShareCodeNotEmpty() builder.WithShareCodeNotEmpty()
builder.WithSorting(user.EntryOrder, user.EntryDirection) builder.WithSorting(user.EntryOrder, user.EntryDirection)
builder.WithSorting("id", user.EntryDirection)
builder.WithOffset(offset) builder.WithOffset(offset)
builder.WithLimit(user.EntriesPerPage) builder.WithLimit(user.EntriesPerPage)

View file

@ -34,6 +34,7 @@ func (h *handler) showTagEntriesAllPage(w http.ResponseWriter, r *http.Request)
builder.WithTags([]string{tagName}) builder.WithTags([]string{tagName})
builder.WithSorting("status", "asc") builder.WithSorting("status", "asc")
builder.WithSorting(user.EntryOrder, user.EntryDirection) builder.WithSorting(user.EntryOrder, user.EntryDirection)
builder.WithSorting("id", user.EntryDirection)
builder.WithOffset(offset) builder.WithOffset(offset)
builder.WithLimit(user.EntriesPerPage) builder.WithLimit(user.EntriesPerPage)

View file

@ -45,6 +45,7 @@ func (h *handler) showUnreadPage(w http.ResponseWriter, r *http.Request) {
builder = h.store.NewEntryQueryBuilder(user.ID) builder = h.store.NewEntryQueryBuilder(user.ID)
builder.WithStatus(model.EntryStatusUnread) builder.WithStatus(model.EntryStatusUnread)
builder.WithSorting(user.EntryOrder, user.EntryDirection) builder.WithSorting(user.EntryOrder, user.EntryDirection)
builder.WithSorting("id", user.EntryDirection)
builder.WithOffset(offset) builder.WithOffset(offset)
builder.WithLimit(user.EntriesPerPage) builder.WithLimit(user.EntriesPerPage)
builder.WithGloballyVisible() builder.WithGloballyVisible()