mirror of
https://github.com/nkanaev/yarr.git
synced 2025-05-24 00:33:14 +00:00
fever item endpoint max_id parameter
This commit is contained in:
parent
b0364087ad
commit
0226c8da23
@ -218,6 +218,13 @@ func FeverItemsHandler(rw http.ResponseWriter, req *http.Request) {
|
||||
}
|
||||
}
|
||||
|
||||
if _, ok := query["max_id"]; ok {
|
||||
idstr := query.Get("max_id")
|
||||
if idnum, err := strconv.ParseInt(idstr, 10, 64); err == nil {
|
||||
filter.MaxID = &idnum
|
||||
}
|
||||
}
|
||||
|
||||
items := db(req).ListItems(filter, 0, 50, true)
|
||||
|
||||
feverItems := make([]FeverItem, len(items))
|
||||
|
@ -65,6 +65,7 @@ type ItemFilter struct {
|
||||
|
||||
IDs *[]int64
|
||||
SinceID *int64
|
||||
MaxID *int64
|
||||
}
|
||||
|
||||
type MarkFilter struct {
|
||||
@ -164,6 +165,10 @@ func listQueryPredicate(filter ItemFilter) (string, []interface{}) {
|
||||
cond = append(cond, "i.id > ?")
|
||||
args = append(args, filter.SinceID)
|
||||
}
|
||||
if filter.MaxID != nil {
|
||||
cond = append(cond, "i.id < ?")
|
||||
args = append(args, filter.MaxID)
|
||||
}
|
||||
|
||||
predicate := "1"
|
||||
if len(cond) > 0 {
|
||||
@ -182,7 +187,7 @@ func (s *Storage) ListItems(filter ItemFilter, offset, limit int, newestFirst bo
|
||||
order = "date asc"
|
||||
}
|
||||
|
||||
if filter.IDs != nil || filter.SinceID != nil {
|
||||
if filter.IDs != nil || filter.SinceID != nil || filter.MaxID != nil {
|
||||
order = "i.id asc"
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user