Add 'list:<id>' search filter
This commit is contained in:
parent
b6aa6d1a4f
commit
697c58e439
@ -3,6 +3,7 @@ package persistence
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -318,6 +319,12 @@ func (c *Cursor) apply_token(token string) error {
|
|||||||
c.LikedByUserHandle = scraper.UserHandle(parts[1])
|
c.LikedByUserHandle = scraper.UserHandle(parts[1])
|
||||||
case "followed_by":
|
case "followed_by":
|
||||||
c.FollowedByUserHandle = scraper.UserHandle(parts[1])
|
c.FollowedByUserHandle = scraper.UserHandle(parts[1])
|
||||||
|
case "list":
|
||||||
|
i, err := strconv.Atoi(parts[1])
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("%w: filter 'list:' must be a number (list ID), got %q", ErrInvalidQuery, parts[1])
|
||||||
|
}
|
||||||
|
c.ListID = scraper.ListID(i)
|
||||||
case "since":
|
case "since":
|
||||||
c.SinceTimestamp.Time, err = time.Parse("2006-01-02", parts[1])
|
c.SinceTimestamp.Time, err = time.Parse("2006-01-02", parts[1])
|
||||||
case "until":
|
case "until":
|
||||||
@ -504,6 +511,7 @@ func (p Profile) NextPage(c Cursor, current_user_id scraper.UserID) (Feed, error
|
|||||||
bind_values = append(bind_values, c.CursorValue)
|
bind_values = append(bind_values, c.CursorValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Assemble the full where-clause
|
||||||
where_clause := ""
|
where_clause := ""
|
||||||
if len(where_clauses) > 0 {
|
if len(where_clauses) > 0 {
|
||||||
where_clause = "where " + strings.Join(where_clauses, " and ")
|
where_clause = "where " + strings.Join(where_clauses, " and ")
|
||||||
@ -563,9 +571,8 @@ func (p Profile) NextPage(c Cursor, current_user_id scraper.UserID) (Feed, error
|
|||||||
|
|
||||||
p.fill_content(&ret.TweetTrove, current_user_id)
|
p.fill_content(&ret.TweetTrove, current_user_id)
|
||||||
|
|
||||||
ret.CursorBottom = c
|
|
||||||
|
|
||||||
// Set the new cursor position and value
|
// Set the new cursor position and value
|
||||||
|
ret.CursorBottom = c // Copy cursor values over
|
||||||
if len(results) < c.PageSize {
|
if len(results) < c.PageSize {
|
||||||
ret.CursorBottom.CursorPosition = CURSOR_END
|
ret.CursorBottom.CursorPosition = CURSOR_END
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user