From 697c58e4393a4ebed4f1d1524660640e6fa64efe Mon Sep 17 00:00:00 2001 From: Alessio Date: Tue, 26 Mar 2024 20:19:17 -0700 Subject: [PATCH] Add 'list:' search filter --- pkg/persistence/compound_ssf_queries.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pkg/persistence/compound_ssf_queries.go b/pkg/persistence/compound_ssf_queries.go index 98f9744..30fdfe1 100644 --- a/pkg/persistence/compound_ssf_queries.go +++ b/pkg/persistence/compound_ssf_queries.go @@ -3,6 +3,7 @@ package persistence import ( "errors" "fmt" + "strconv" "strings" "time" @@ -318,6 +319,12 @@ func (c *Cursor) apply_token(token string) error { c.LikedByUserHandle = scraper.UserHandle(parts[1]) case "followed_by": 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": c.SinceTimestamp.Time, err = time.Parse("2006-01-02", parts[1]) 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) } + // Assemble the full where-clause where_clause := "" if len(where_clauses) > 0 { 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) - ret.CursorBottom = c - // Set the new cursor position and value + ret.CursorBottom = c // Copy cursor values over if len(results) < c.PageSize { ret.CursorBottom.CursorPosition = CURSOR_END } else {