Fix giant lists
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"net/http"
|
||||
"regexp"
|
||||
"sort"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/mmcdole/gofeed"
|
||||
@@ -125,7 +126,7 @@ func (f *Feed) Items(limit int) ([]*Item, error) {
|
||||
}
|
||||
|
||||
func (f *Feed) List(limit int) ([]string, error) {
|
||||
keys, err := config.Values().DB.List([]string{nsItems, f.Key})
|
||||
keys, err := config.Values().DB.List([]string{nsItems, f.Key}, " ", "}}}}}", strconv.Itoa(limit), "-")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -177,3 +177,37 @@ func TestRSSFeedPull(t *testing.T) {
|
||||
t.Fatal(i)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRSSFeedListLimitedDescending(t *testing.T) {
|
||||
initRSSFeed()
|
||||
|
||||
s := mockRSS()
|
||||
defer s.Close()
|
||||
|
||||
f := newFeed("key")
|
||||
f.TitleFilter = "50."
|
||||
f.ContentFilter = "b"
|
||||
f.Tags = []string{"c"}
|
||||
f.URL = s.URL
|
||||
|
||||
log.SetOutput(bytes.NewBuffer(nil))
|
||||
defer log.SetOutput(os.Stderr)
|
||||
if err := f.Pull(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
log.SetOutput(os.Stderr)
|
||||
|
||||
itemKeys, err := f.List(5)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(itemKeys) != 5 {
|
||||
t.Fatal(len(itemKeys))
|
||||
}
|
||||
|
||||
for i := range itemKeys {
|
||||
if i > 0 && itemKeys[i] > itemKeys[i-1] {
|
||||
t.Error(itemKeys[i], ">", itemKeys[i-1])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user