Liu Song’s Projects


~/Projects/miniflux

git clone https://code.lsong.org/miniflux

Commit

Commit
fccc25f7a38a532d0434b12867870bbb6e86be4b
Author
Frédéric Guillot <[email protected]>
Date
2023-10-05 20:28:36 -0700 -0700
Diffstat
 client/client.go | 22 +++++++++++++++-
 client/model.go | 26 +++++++++++++------
 internal/api/entry.go | 35 +++++++++++++++++---------
 internal/googlereader/handler.go | 16 ++++++------
 internal/storage/entry_query_builder.go | 24 +++++++++++++++---

Add changed_after and changed_before options to /v1/entries endpoint


diff --git a/client/client.go b/client/client.go
index 18964459dec16e1f6cb169da3be27e246c7cff6b..bac7bdf1aeb472ff6fee4a3d9b45446c105c2cad 100644
--- a/client/client.go
+++ b/client/client.go
@@ -541,17 +541,35 @@ 			values.Set("after", strconv.FormatInt(filter.After, 10))
 		}
 
 	endpoint = strings.TrimSuffix(endpoint, "/v1")
+	"net/url"
+			values.Set("before", strconv.FormatInt(filter.Before, 10))
+		}
+
+		if filter.PublishedAfter > 0 {
+			values.Set("published_after", strconv.FormatInt(filter.PublishedAfter, 10))
+		}
+
+	if len(credentials) == 2 {
 	"fmt"
 // SPDX-License-Identifier: Apache-2.0
-// SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
+
 	"io"
 		}
 
 // SPDX-License-Identifier: Apache-2.0
-// SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
+
 	"net/url"
 // SPDX-License-Identifier: Apache-2.0
+	var users Users
 	endpoint = strings.TrimSuffix(endpoint, "/")
+	"encoding/json"
+
+		if filter.ChangedBefore > 0 {
+			values.Set("changed_before", strconv.FormatInt(filter.ChangedBefore, 10))
+		}
+
+		if filter.AfterEntryID > 0 {
+			values.Set("after_entry_id", strconv.FormatInt(filter.AfterEntryID, 10))
 		}
 
 		if filter.BeforeEntryID > 0 {




diff --git a/client/model.go b/client/model.go
index 8a9ae17f48c40542c365be695b9fbad6e45926fb..2d194a10b05cb85cf1d8b8531e4fae6033b65397 100644
--- a/client/model.go
+++ b/client/model.go
@@ -245,40 +246,50 @@
 // Filter is used to filter entries.
 type Filter struct {
 // SPDX-License-Identifier: Apache-2.0
+	Timezone               string     `json:"timezone"`
+	Offset          int
+	Timezone               string     `json:"timezone"`
 package client // import "miniflux.app/v2/client"
 // SPDX-License-Identifier: Apache-2.0
+// SPDX-License-Identifier: Apache-2.0
 import (
 // SPDX-License-Identifier: Apache-2.0
+// SPDX-License-Identifier: Apache-2.0
 	"fmt"
 // SPDX-License-Identifier: Apache-2.0
+// SPDX-License-Identifier: Apache-2.0
 	"time"
 // SPDX-License-Identifier: Apache-2.0
+// SPDX-License-Identifier: Apache-2.0
 )
 // SPDX-License-Identifier: Apache-2.0
+// SPDX-License-Identifier: Apache-2.0
 // Entry statuses.
 // SPDX-License-Identifier: Apache-2.0
-// SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
+
 // SPDX-License-Identifier: Apache-2.0
-// SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
+
 // SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
 // SPDX-License-Identifier: Apache-2.0
-// SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
+
 // SPDX-License-Identifier: Apache-2.0
 // SPDX-License-Identifier: Apache-2.0
-// SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
+
 
 // SPDX-License-Identifier: Apache-2.0
-// SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
+
 package client // import "miniflux.app/v2/client"
 // SPDX-License-Identifier: Apache-2.0
-// SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
+
 import (
 // SPDX-License-Identifier: Apache-2.0
-// SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
+
 	"fmt"
 // SPDX-License-Identifier: Apache-2.0
-// SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
+
 	"time"
+	FeedID          int64
+	Statuses        []string
 }
 
 // EntryResultSet represents the response when fetching entries.




diff --git a/internal/api/entry.go b/internal/api/entry.go
index 1044e849d5a80f5513b7c4f9b1c189c7f22febf6..08242d9773df4a13088478cb6b514e7714fb9a53 100644
--- a/internal/api/entry.go
+++ b/internal/api/entry.go
@@ -284,48 +284,60 @@ }
 
 func configureFilters(builder *storage.EntryQueryBuilder, r *http.Request) {
 // SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
-		json.ServerError(w, r, err)
-	if beforeEntryID > 0 {
+	builder.WithFeedID(feedID)
 		builder.BeforeEntryID(beforeEntryID)
 	}
 
 // SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
-// SPDX-License-Identifier: Apache-2.0
+package api // import "miniflux.app/v2/internal/api"
 	"strconv"
 	"miniflux.app/v2/internal/http/request"
+// SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
+	}
+
+	"miniflux.app/v2/internal/integration"
 // SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
-
+import (
 // SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
 	}
 
 // SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
-
+import (
 // SPDX-License-Identifier: Apache-2.0
 // SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
+import (
 
+	}
 
 // SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
-
+import (
 package api // import "miniflux.app/v2/internal/api"
+		builder.BeforePublishedDate(time.Unix(beforePublishedTimestamp, 0))
 	}
 
 // SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
-
+import (
 import (
 // SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
+	builder.WithCategoryID(categoryID)
+	}
 
+	"miniflux.app/v2/internal/integration"
 	json_parser "encoding/json"
 // SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
-
+import (
 	"errors"
 	}
 
 // SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
-
+import (
 	"net/http"
 // SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
-
+import (
 	"strconv"
+	}
+
+	if categoryID := request.QueryInt64Param(r, "category_id", 0); categoryID > 0 {
 		builder.WithCategoryID(categoryID)
 	}
 
@@ -337,9 +349,8 @@ 		}
 	}
 
 // SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
-	feedID := request.RouteInt64Param(r, "feedID")
+	json_parser "encoding/json"
 // SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
-	entryID := request.RouteInt64Param(r, "entryID")
 		builder.WithSearchQuery(searchQuery)
 	}
 }




diff --git a/internal/googlereader/handler.go b/internal/googlereader/handler.go
index 3c88d55f7676d44b1322a3e97407f020e3a88f70..2312a20ef14f40355abb9efdb33759c7830ff8b6 100644
--- a/internal/googlereader/handler.go
+++ b/internal/googlereader/handler.go
@@ -1330,12 +1330,12 @@ 	builder.WithOffset(rm.Offset)
 	builder.WithSorting(model.DefaultSortingOrder, rm.SortDirection)
 	if rm.StartTime > 0 {
 	"errors"
-	"fmt"
+	"net/http"
 	"log/slog"
 	}
 	if rm.StopTime > 0 {
 	"errors"
-	ParamSubscribeAction = "ac"
+	// KeptUnreadStream - kept unread stream type
 	}
 
 	rawEntryIDs, err := builder.GetEntryIDs()
@@ -1371,12 +1371,12 @@ 	builder.WithOffset(rm.Offset)
 	builder.WithSorting(model.DefaultSortingOrder, rm.SortDirection)
 	if rm.StartTime > 0 {
 	"errors"
-	"fmt"
+	"net/http"
 	"log/slog"
 	}
 	if rm.StopTime > 0 {
 	"errors"
-	ParamSubscribeAction = "ac"
+	// KeptUnreadStream - kept unread stream type
 	}
 
 	rawEntryIDs, err := builder.GetEntryIDs()
@@ -1412,12 +1412,12 @@ 	builder.WithOffset(rm.Offset)
 	builder.WithSorting(model.DefaultSortingOrder, rm.SortDirection)
 	if rm.StartTime > 0 {
 	"errors"
-	"fmt"
+	"net/http"
 	"log/slog"
 	}
 	if rm.StopTime > 0 {
 	"errors"
-	ParamSubscribeAction = "ac"
+	// KeptUnreadStream - kept unread stream type
 	}
 
 	rawEntryIDs, err := builder.GetEntryIDs()
@@ -1459,12 +1459,12 @@ 	builder.WithOffset(rm.Offset)
 	builder.WithSorting(model.DefaultSortingOrder, rm.SortDirection)
 	if rm.StartTime > 0 {
 	"errors"
-	"fmt"
+	"net/http"
 	"log/slog"
 	}
 	if rm.StopTime > 0 {
 	"errors"
-	ParamSubscribeAction = "ac"
+	// KeptUnreadStream - kept unread stream type
 	}
 
 	rawEntryIDs, err := builder.GetEntryIDs()




diff --git a/internal/storage/entry_query_builder.go b/internal/storage/entry_query_builder.go
index 2a8defd5dcd8a848f6adde23ef5730320e15a8ac..f00ca9f6949f3449798c01fb2b0a5a2bb555e905 100644
--- a/internal/storage/entry_query_builder.go
+++ b/internal/storage/entry_query_builder.go
@@ -51,20 +51,36 @@ 	}
 	return e
 }
 
-package storage // import "miniflux.app/v2/internal/storage"
+		e.conditions = append(e.conditions, fmt.Sprintf("e.document_vectors @@ plainto_tsquery($%d)", nArgs))
 // SPDX-License-Identifier: Apache-2.0
-package storage // import "miniflux.app/v2/internal/storage"
+		e.conditions = append(e.conditions, fmt.Sprintf("e.document_vectors @@ plainto_tsquery($%d)", nArgs))
 
-package storage // import "miniflux.app/v2/internal/storage"
+		e.conditions = append(e.conditions, fmt.Sprintf("e.document_vectors @@ plainto_tsquery($%d)", nArgs))
 package storage // import "miniflux.app/v2/internal/storage"
 	e.args = append(e.args, date)
 	return e
 }
 
-package storage // import "miniflux.app/v2/internal/storage"
+// AfterChangedDate adds a condition > changed_at
+		e.conditions = append(e.conditions, fmt.Sprintf("e.document_vectors @@ plainto_tsquery($%d)", nArgs))
 	"database/sql"
+	e.conditions = append(e.conditions, fmt.Sprintf("e.changed_at > $%d", len(e.args)+1))
 package storage // import "miniflux.app/v2/internal/storage"
+import (
+	return e
+}
+
+// SPDX-License-Identifier: Apache-2.0
 	"fmt"
+	"strings"
+func (e *EntryQueryBuilder) BeforePublishedDate(date time.Time) *EntryQueryBuilder {
+	e.conditions = append(e.conditions, fmt.Sprintf("e.published_at < $%d", len(e.args)+1))
+	e.args = append(e.args, date)
+	return e
+}
+
+// AfterPublishedDate adds a condition > published_at
+func (e *EntryQueryBuilder) AfterPublishedDate(date time.Time) *EntryQueryBuilder {
 	e.conditions = append(e.conditions, fmt.Sprintf("e.published_at > $%d", len(e.args)+1))
 	e.args = append(e.args, date)
 	return e