From ff406be68f0fe6fc0b2dae9a091ce164ac039b3f Mon Sep 17 00:00:00 2001 From: Tobi Smethurst <31960611+tsmethurst@users.noreply.github.com> Date: Sun, 15 Aug 2021 18:43:08 +0200 Subject: Timeline loop fix (#140) * uwu we made a fucky wucky * uwu we made a fucky wucky * work on timeline fixes a little * fiddle with tests some more * bleep bloop more tests * more tests * update drone yml * update some sturf * make the timeline code a bit lazier * go fmt * fix drone.yml --- internal/timeline/timeline.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'internal/timeline/timeline.go') diff --git a/internal/timeline/timeline.go b/internal/timeline/timeline.go index 20015a745..6274a86ac 100644 --- a/internal/timeline/timeline.go +++ b/internal/timeline/timeline.go @@ -38,7 +38,10 @@ type Timeline interface { RETRIEVAL FUNCTIONS */ - Get(amount int, maxID string, sinceID string, minID string) ([]*apimodel.Status, error) + // Get returns an amount of statuses with the given parameters. + // If prepareNext is true, then the next predicted query will be prepared already in a goroutine, + // to make the next call to Get faster. + Get(amount int, maxID string, sinceID string, minID string, prepareNext bool) ([]*apimodel.Status, error) // GetXFromTop returns x amount of posts from the top of the timeline, from newest to oldest. GetXFromTop(amount int) ([]*apimodel.Status, error) // GetXBehindID returns x amount of posts from the given id onwards, from newest to oldest. @@ -50,7 +53,7 @@ type Timeline interface { // This will NOT include the status with the given ID. // // This corresponds to an api call to /timelines/home?since_id=WHATEVER - GetXBeforeID(amount int, sinceID string, startFromTop bool, attempts *int) ([]*apimodel.Status, error) + GetXBeforeID(amount int, sinceID string, startFromTop bool) ([]*apimodel.Status, error) // GetXBetweenID returns x amount of posts from the given maxID, up to the given id, from newest to oldest. // This will NOT include the status with the given IDs. // @@ -70,6 +73,12 @@ type Timeline interface { // OldestIndexedPostID returns the id of the rearmost (ie., the oldest) indexed post, or an error if something goes wrong. // If nothing goes wrong but there's no oldest post, an empty string will be returned so make sure to check for this. OldestIndexedPostID() (string, error) + // NewestIndexedPostID returns the id of the frontmost (ie., the newest) indexed post, or an error if something goes wrong. + // If nothing goes wrong but there's no newest post, an empty string will be returned so make sure to check for this. + NewestIndexedPostID() (string, error) + + IndexBefore(statusID string, include bool, amount int) error + IndexBehind(statusID string, include bool, amount int) error /* PREPARATION FUNCTIONS -- cgit v1.2.3