mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-14 20:14:47 +00:00
support limit offset in rss
This commit is contained in:
@@ -84,13 +84,13 @@ func (e *Rss) fetch(f *pb.Feed) error {
|
||||
}
|
||||
|
||||
err = e.entries.Create(pb.Entry{
|
||||
Id: id,
|
||||
Title: item.Title,
|
||||
Summary: item.Summary,
|
||||
Feed: f.Url,
|
||||
Link: item.Link,
|
||||
Content: content,
|
||||
Date: item.Date.Format(time.RFC3339Nano),
|
||||
Id: id,
|
||||
Title: item.Title,
|
||||
Summary: item.Summary,
|
||||
Feed: f.Url,
|
||||
Link: item.Link,
|
||||
Content: content,
|
||||
Date: item.Date.Format(time.RFC3339Nano),
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error saving item: %v", err)
|
||||
|
||||
@@ -118,6 +118,21 @@ func (e *Rss) Feed(ctx context.Context, req *pb.FeedRequest, rsp *pb.FeedRespons
|
||||
feed := new(pb.Feed)
|
||||
id := tenantID + "/" + idFromName(req.Name)
|
||||
q := model.QueryEquals("ID", id)
|
||||
q.Limit = int64(25)
|
||||
q.Order = model.Order{
|
||||
Type: model.OrderTypeDesc,
|
||||
FieldName: "ID",
|
||||
}
|
||||
|
||||
if req.Limit > 0 {
|
||||
q.Limit = req.Limit
|
||||
}
|
||||
if req.Offset > 0 {
|
||||
q.Offset = req.Offset
|
||||
}
|
||||
if req.Order == "asc" {
|
||||
q.Order.Type = model.OrderTypeAsc
|
||||
}
|
||||
|
||||
// get the feed
|
||||
if err := e.feeds.Read(q, feed); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user