1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-09-15 18:57:04 +00:00

Refactor entry/feed query builder sorting to match SQL semantic

This commit is contained in:
fred 2023-06-19 14:00:10 -07:00 committed by Frédéric Guillot
parent 095bec072c
commit 28775f5e10
15 changed files with 44 additions and 79 deletions

View file

@ -26,8 +26,7 @@ func (h *handler) showStarredPage(w http.ResponseWriter, r *http.Request) {
builder := h.store.NewEntryQueryBuilder(user.ID)
builder.WithoutStatus(model.EntryStatusRemoved)
builder.WithStarred(true)
builder.WithOrder(user.EntryOrder)
builder.WithDirection(user.EntryDirection)
builder.WithSorting(user.EntryOrder, user.EntryDirection)
builder.WithOffset(offset)
builder.WithLimit(user.EntriesPerPage)

View file

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

View file

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

View file

@ -38,8 +38,7 @@ func (h *handler) showFeedEntriesPage(w http.ResponseWriter, r *http.Request) {
builder := h.store.NewEntryQueryBuilder(user.ID)
builder.WithFeedID(feed.ID)
builder.WithStatus(model.EntryStatusUnread)
builder.WithOrder(user.EntryOrder)
builder.WithDirection(user.EntryDirection)
builder.WithSorting(user.EntryOrder, user.EntryDirection)
builder.WithOffset(offset)
builder.WithLimit(user.EntriesPerPage)

View file

@ -38,8 +38,7 @@ func (h *handler) showFeedEntriesAllPage(w http.ResponseWriter, r *http.Request)
builder := h.store.NewEntryQueryBuilder(user.ID)
builder.WithFeedID(feed.ID)
builder.WithoutStatus(model.EntryStatusRemoved)
builder.WithOrder(user.EntryOrder)
builder.WithDirection(user.EntryDirection)
builder.WithSorting(user.EntryOrder, user.EntryDirection)
builder.WithOffset(offset)
builder.WithLimit(user.EntriesPerPage)

View file

@ -25,7 +25,8 @@ func (h *handler) showHistoryPage(w http.ResponseWriter, r *http.Request) {
offset := request.QueryIntParam(r, "offset", 0)
builder := h.store.NewEntryQueryBuilder(user.ID)
builder.WithStatus(model.EntryStatusRead)
builder.WithOrder("changed_at DESC, published_at DESC")
builder.WithSorting("changed_at", "DESC")
builder.WithSorting("published_at", "DESC")
builder.WithOffset(offset)
builder.WithLimit(user.EntriesPerPage)

View file

@ -22,8 +22,7 @@ func (h *handler) sharedEntries(w http.ResponseWriter, r *http.Request) {
builder := h.store.NewEntryQueryBuilder(user.ID)
builder.WithShareCodeNotEmpty()
builder.WithOrder(user.EntryOrder)
builder.WithDirection(user.EntryDirection)
builder.WithSorting(user.EntryOrder, user.EntryDirection)
entries, err := builder.GetEntries()
if err != nil {

View file

@ -49,8 +49,7 @@ func (h *handler) showUnreadPage(w http.ResponseWriter, r *http.Request) {
beginSqlFetchUnreadEntries := time.Now()
builder = h.store.NewEntryQueryBuilder(user.ID)
builder.WithStatus(model.EntryStatusUnread)
builder.WithOrder(user.EntryOrder)
builder.WithDirection(user.EntryDirection)
builder.WithSorting(user.EntryOrder, user.EntryDirection)
builder.WithOffset(offset)
builder.WithLimit(user.EntriesPerPage)
builder.WithGloballyVisible()