You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When fetch items using the Fever API, if the query parameter is max_id, it seems that ORDER BY id DESC is not being used correctly.
When I use max_id to fetch all articles, I need to retrieve the minId in descending order so that it can be used as the maxId in the next loop for querying. However, I've noticed that the data I get is in ascending order, and the minId I obtain cannot be used to continue querying.
I looked into the code for the Fever API handler in Miniflux v2 and found that the sorting method is set at the beginning of the query, which prevents max_id queries from being ordered by id in descending order later.
func (h *handler) handleItems(w http.ResponseWriter, r *http.Request) {
var result itemsResponse
userID := request.UserID(r)
builder := h.store.NewEntryQueryBuilder(userID)
builder.WithoutStatus(model.EntryStatusRemoved)
builder.WithLimit(50)
builder.WithSorting("id", model.DefaultSortingDirection) //default sort!!!!!
...
}
case request.HasQueryParam(r, "max_id"):
maxID := request.QueryInt64Param(r, "max_id", 0)
if maxID == 0 {
slog.Debug("[Fever] Fetching most recent items",
slog.Int64("user_id", userID),
)
builder.WithSorting("id", "DESC")
} else if maxID > 0 {
slog.Debug("[Fever] Fetching items before a given item ID",
slog.Int64("user_id", userID),
slog.Int64("max_id", maxID),
)
builder.BeforeEntryID(maxID)
builder.WithSorting("id", "DESC")
}
final sql
SELECT
e.id,
e.user_id,
e.feed_id,
e.hash,
e.published_at at time zone u.timezone,
e.title,
e.url,
e.comments_url,
e.author,
e.share_code,
e.content,
e.status,
e.starred,
e.reading_time,
e.created_at,
e.changed_at,
e.tags,
(SELECT true FROM enclosures WHERE entry_id=e.id LIMIT 1) as has_enclosure,
f.title as feed_title,
f.feed_url,
f.site_url,
f.description,
f.checked_at,
f.category_id,
c.title as category_title,
c.hide_globally as category_hidden,
f.scraper_rules,
f.rewrite_rules,
f.crawler,
f.user_agent,
f.cookie,
f.hide_globally,
f.no_media_player,
fi.icon_id,
u.timezone
FROM
entries e
LEFT JOIN
feeds f ON f.id=e.feed_id
LEFT JOIN
categories c ON c.id=f.category_id
LEFT JOIN
feed_icons fi ON fi.feed_id=f.id
LEFT JOIN
users u ON u.id=e.user_id
WHERE e.user_id = $1 AND e.status <> $2 AND e.id < $3 ORDER BY id asc, id DESC LIMIT 50 ##### error sort!!!
I'm not sure if this sorting method is correct and would like to get some clarification.
The text was updated successfully, but these errors were encountered:
When fetch items using the Fever API, if the query parameter is max_id, it seems that ORDER BY id DESC is not being used correctly.
When I use max_id to fetch all articles, I need to retrieve the minId in descending order so that it can be used as the maxId in the next loop for querying. However, I've noticed that the data I get is in ascending order, and the minId I obtain cannot be used to continue querying.
I looked into the code for the Fever API handler in Miniflux v2 and found that the sorting method is set at the beginning of the query, which prevents max_id queries from being ordered by id in descending order later.
final sql
I'm not sure if this sorting method is correct and would like to get some clarification.
The text was updated successfully, but these errors were encountered: