mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-25 01:03:32 -06:00
parent
8c9a853343
commit
16e486ad96
5 changed files with 100 additions and 26 deletions
|
|
@ -10,6 +10,45 @@ import (
|
|||
)
|
||||
|
||||
func (t *timeline) IndexBefore(statusID string, include bool, amount int) error {
|
||||
filtered := []*gtsmodel.Status{}
|
||||
offsetStatus := statusID
|
||||
|
||||
if include {
|
||||
s := >smodel.Status{}
|
||||
if err := t.db.GetByID(statusID, s); err != nil {
|
||||
return fmt.Errorf("IndexBefore: error getting initial status with id %s: %s", statusID, err)
|
||||
}
|
||||
filtered = append(filtered, s)
|
||||
}
|
||||
|
||||
grabloop:
|
||||
for len(filtered) < amount {
|
||||
statuses, err := t.db.GetStatusesWhereFollowing(t.accountID, "", offsetStatus, "", amount, false)
|
||||
if err != nil {
|
||||
if _, ok := err.(db.ErrNoEntries); ok {
|
||||
break grabloop // we just don't have enough statuses left in the db so index what we've got and then bail
|
||||
}
|
||||
return fmt.Errorf("IndexBefore: error getting statuses from db: %s", err)
|
||||
}
|
||||
|
||||
for _, s := range statuses {
|
||||
timelineable, err := t.filter.StatusHometimelineable(s, t.account)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
if timelineable {
|
||||
filtered = append(filtered, s)
|
||||
}
|
||||
offsetStatus = s.ID
|
||||
}
|
||||
}
|
||||
|
||||
for _, s := range filtered {
|
||||
if _, err := t.IndexOne(s.CreatedAt, s.ID, s.BoostOfID); err != nil {
|
||||
return fmt.Errorf("IndexBefore: error indexing status with id %s: %s", s.ID, err)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
@ -41,7 +80,7 @@ grabloop:
|
|||
|
||||
for _, s := range filtered {
|
||||
if _, err := t.IndexOne(s.CreatedAt, s.ID, s.BoostOfID); err != nil {
|
||||
return fmt.Errorf("IndexBehindAndIncluding: error indexing status with id %s: %s", s.ID, err)
|
||||
return fmt.Errorf("IndexBehind: error indexing status with id %s: %s", s.ID, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue