소스 검색

fix(fever): correct sorting direction when using max_id argument

Frédéric Guillot 1 년 전
부모
커밋
f3a5a3ee14
2개의 변경된 파일4개의 추가작업 그리고 4개의 파일을 삭제
  1. 1 1
      internal/fever/handler.go
  2. 3 3
      internal/storage/entry_query_builder.go

+ 1 - 1
internal/fever/handler.go

@@ -247,7 +247,6 @@ func (h *handler) handleItems(w http.ResponseWriter, r *http.Request) {
 	builder := h.store.NewEntryQueryBuilder(userID)
 	builder.WithoutStatus(model.EntryStatusRemoved)
 	builder.WithLimit(50)
-	builder.WithSorting("id", model.DefaultSortingDirection)
 
 	switch {
 	case request.HasQueryParam(r, "since_id"):
@@ -258,6 +257,7 @@ func (h *handler) handleItems(w http.ResponseWriter, r *http.Request) {
 				slog.Int64("since_id", sinceID),
 			)
 			builder.AfterEntryID(sinceID)
+			builder.WithSorting("id", "ASC")
 		}
 	case request.HasQueryParam(r, "max_id"):
 		maxID := request.QueryInt64Param(r, "max_id", 0)

+ 3 - 3
internal/storage/entry_query_builder.go

@@ -402,13 +402,13 @@ func (e *EntryQueryBuilder) GetEntryIDs() ([]int64, error) {
 	query := `
 		SELECT
 			e.id
-		FROM 
+		FROM
 			entries e
 		LEFT JOIN
 			feeds f
 		ON
-			f.id=e.feed_id 
-		WHERE 
+			f.id=e.feed_id
+		WHERE
 			%s %s
 	`