mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-12-01 02:13:33 -06:00
[chore] tidy + test timelines a bit better (#1865)
* [chore] tidy + test timelines a bit better * thanks linter
This commit is contained in:
parent
186e849dbf
commit
97bc2e713a
12 changed files with 685 additions and 479 deletions
|
|
@ -19,7 +19,6 @@ package timeline
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
|
|
@ -76,6 +75,9 @@ type Manager interface {
|
|||
// WipeStatusesFromAccountID removes all items by the given accountID from the given timeline.
|
||||
WipeItemsFromAccountID(ctx context.Context, timelineID string, accountID string) error
|
||||
|
||||
// Prune manually triggers a prune operation for the given timelineID.
|
||||
Prune(ctx context.Context, timelineID string, desiredPreparedItemsLength int, desiredIndexedItemsLength int) (int, error)
|
||||
|
||||
// Start starts hourly cleanup jobs for this timeline manager.
|
||||
Start() error
|
||||
|
||||
|
|
@ -191,7 +193,7 @@ func (m *manager) WipeItemFromAllTimelines(ctx context.Context, itemID string) e
|
|||
})
|
||||
|
||||
if len(errors) > 0 {
|
||||
return fmt.Errorf("WipeItemFromAllTimelines: one or more errors wiping status %s: %w", itemID, errors.Combine())
|
||||
return gtserror.Newf("one or more errors wiping status %s: %w", itemID, errors.Combine())
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
@ -202,6 +204,10 @@ func (m *manager) WipeItemsFromAccountID(ctx context.Context, timelineID string,
|
|||
return err
|
||||
}
|
||||
|
||||
func (m *manager) Prune(ctx context.Context, timelineID string, desiredPreparedItemsLength int, desiredIndexedItemsLength int) (int, error) {
|
||||
return m.getOrCreateTimeline(ctx, timelineID).Prune(desiredPreparedItemsLength, desiredIndexedItemsLength), nil
|
||||
}
|
||||
|
||||
// getOrCreateTimeline returns a timeline with the given id,
|
||||
// creating a new timeline with that id if necessary.
|
||||
func (m *manager) getOrCreateTimeline(ctx context.Context, timelineID string) Timeline {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue