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:
parent
9c82e55b98
commit
400e8974f9
10 changed files with 12 additions and 3 deletions
|
@ -112,13 +112,13 @@ func (e *EntryPaginationBuilder) getPrevNextID(tx *sql.Tx) (prevID int64, nextID
|
|||
WITH entry_pagination AS (
|
||||
SELECT
|
||||
e.id,
|
||||
lag(e.id) over (order by e.%[1]s asc, e.id desc) as prev_id,
|
||||
lead(e.id) over (order by e.%[1]s asc, e.id desc) as next_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.created_at asc, e.id desc) as next_id
|
||||
FROM entries AS e
|
||||
JOIN feeds AS f ON f.id=e.feed_id
|
||||
JOIN categories c ON c.id = f.category_id
|
||||
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;
|
||||
`
|
||||
|
|
|
@ -26,6 +26,7 @@ func (h *handler) showStarredPage(w http.ResponseWriter, r *http.Request) {
|
|||
builder.WithoutStatus(model.EntryStatusRemoved)
|
||||
builder.WithStarred(true)
|
||||
builder.WithSorting(user.EntryOrder, user.EntryDirection)
|
||||
builder.WithSorting("id", user.EntryDirection)
|
||||
builder.WithOffset(offset)
|
||||
builder.WithLimit(user.EntriesPerPage)
|
||||
|
||||
|
|
|
@ -37,6 +37,7 @@ func (h *handler) showCategoryEntriesPage(w http.ResponseWriter, r *http.Request
|
|||
builder := h.store.NewEntryQueryBuilder(user.ID)
|
||||
builder.WithCategoryID(category.ID)
|
||||
builder.WithSorting(user.EntryOrder, user.EntryDirection)
|
||||
builder.WithSorting("id", user.EntryDirection)
|
||||
builder.WithStatus(model.EntryStatusUnread)
|
||||
builder.WithOffset(offset)
|
||||
builder.WithLimit(user.EntriesPerPage)
|
||||
|
|
|
@ -37,6 +37,7 @@ func (h *handler) showCategoryEntriesAllPage(w http.ResponseWriter, r *http.Requ
|
|||
builder := h.store.NewEntryQueryBuilder(user.ID)
|
||||
builder.WithCategoryID(category.ID)
|
||||
builder.WithSorting(user.EntryOrder, user.EntryDirection)
|
||||
builder.WithSorting("id", user.EntryDirection)
|
||||
builder.WithoutStatus(model.EntryStatusRemoved)
|
||||
builder.WithOffset(offset)
|
||||
builder.WithLimit(user.EntriesPerPage)
|
||||
|
|
|
@ -37,6 +37,7 @@ func (h *handler) showCategoryEntriesStarredPage(w http.ResponseWriter, r *http.
|
|||
builder := h.store.NewEntryQueryBuilder(user.ID)
|
||||
builder.WithCategoryID(category.ID)
|
||||
builder.WithSorting(user.EntryOrder, user.EntryDirection)
|
||||
builder.WithSorting("id", user.EntryDirection)
|
||||
builder.WithoutStatus(model.EntryStatusRemoved)
|
||||
builder.WithStarred(true)
|
||||
builder.WithOffset(offset)
|
||||
|
|
|
@ -38,6 +38,7 @@ func (h *handler) showFeedEntriesPage(w http.ResponseWriter, r *http.Request) {
|
|||
builder.WithFeedID(feed.ID)
|
||||
builder.WithStatus(model.EntryStatusUnread)
|
||||
builder.WithSorting(user.EntryOrder, user.EntryDirection)
|
||||
builder.WithSorting("id", user.EntryDirection)
|
||||
builder.WithOffset(offset)
|
||||
builder.WithLimit(user.EntriesPerPage)
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@ func (h *handler) showFeedEntriesAllPage(w http.ResponseWriter, r *http.Request)
|
|||
builder.WithFeedID(feed.ID)
|
||||
builder.WithoutStatus(model.EntryStatusRemoved)
|
||||
builder.WithSorting(user.EntryOrder, user.EntryDirection)
|
||||
builder.WithSorting("id", user.EntryDirection)
|
||||
builder.WithOffset(offset)
|
||||
builder.WithLimit(user.EntriesPerPage)
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ func (h *handler) sharedEntries(w http.ResponseWriter, r *http.Request) {
|
|||
builder := h.store.NewEntryQueryBuilder(user.ID)
|
||||
builder.WithShareCodeNotEmpty()
|
||||
builder.WithSorting(user.EntryOrder, user.EntryDirection)
|
||||
builder.WithSorting("id", user.EntryDirection)
|
||||
builder.WithOffset(offset)
|
||||
builder.WithLimit(user.EntriesPerPage)
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ func (h *handler) showTagEntriesAllPage(w http.ResponseWriter, r *http.Request)
|
|||
builder.WithTags([]string{tagName})
|
||||
builder.WithSorting("status", "asc")
|
||||
builder.WithSorting(user.EntryOrder, user.EntryDirection)
|
||||
builder.WithSorting("id", user.EntryDirection)
|
||||
builder.WithOffset(offset)
|
||||
builder.WithLimit(user.EntriesPerPage)
|
||||
|
||||
|
|
|
@ -45,6 +45,7 @@ func (h *handler) showUnreadPage(w http.ResponseWriter, r *http.Request) {
|
|||
builder = h.store.NewEntryQueryBuilder(user.ID)
|
||||
builder.WithStatus(model.EntryStatusUnread)
|
||||
builder.WithSorting(user.EntryOrder, user.EntryDirection)
|
||||
builder.WithSorting("id", user.EntryDirection)
|
||||
builder.WithOffset(offset)
|
||||
builder.WithLimit(user.EntriesPerPage)
|
||||
builder.WithGloballyVisible()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue