mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-29 04:52:24 -05:00
Database updates (#144)
* start moving some database stuff around * continue moving db stuff around * more fiddling * more updates * and some more * and yet more * i broke SOMETHING but what, it's a mystery * tidy up * vendor ttlcache * use ttlcache * fix up some tests * rename some stuff * little reminder * some more updates
This commit is contained in:
parent
ce190d867c
commit
4920229a3b
164 changed files with 4850 additions and 2617 deletions
|
|
@ -50,9 +50,9 @@ func (t *timeline) IndexBefore(statusID string, include bool, amount int) error
|
|||
i := 0
|
||||
grabloop:
|
||||
for ; len(filtered) < amount && i < 5; i = i + 1 { // try the grabloop 5 times only
|
||||
statuses, err := t.db.GetHomeTimelineForAccount(t.accountID, "", "", offsetStatus, amount, false)
|
||||
statuses, err := t.db.GetHomeTimeline(t.accountID, "", "", offsetStatus, amount, false)
|
||||
if err != nil {
|
||||
if _, ok := err.(db.ErrNoEntries); ok {
|
||||
if err == db.ErrNoEntries {
|
||||
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)
|
||||
|
|
@ -130,9 +130,9 @@ positionLoop:
|
|||
grabloop:
|
||||
for ; len(filtered) < amount && i < 5; i = i + 1 { // try the grabloop 5 times only
|
||||
l.Tracef("entering grabloop; i is %d; len(filtered) is %d", i, len(filtered))
|
||||
statuses, err := t.db.GetHomeTimelineForAccount(t.accountID, offsetStatus, "", "", amount, false)
|
||||
statuses, err := t.db.GetHomeTimeline(t.accountID, offsetStatus, "", "", amount, false)
|
||||
if err != nil {
|
||||
if _, ok := err.(db.ErrNoEntries); ok {
|
||||
if err == db.ErrNoEntries {
|
||||
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("IndexBehind: error getting statuses from db: %s", err)
|
||||
|
|
|
|||
|
|
@ -67,9 +67,8 @@ func (suite *IndexTestSuite) TestIndexBeforeLowID() {
|
|||
suite.NoError(err)
|
||||
suite.Equal("01F8MHAAY43M6RJ473VQFCVH37", postID)
|
||||
|
||||
// indexLength should only be 9 because that's all this user has hometimelineable
|
||||
indexLength := suite.timeline.PostIndexLength()
|
||||
suite.Equal(9, indexLength)
|
||||
suite.Equal(10, indexLength)
|
||||
}
|
||||
|
||||
func (suite *IndexTestSuite) TestIndexBeforeHighID() {
|
||||
|
|
@ -97,9 +96,9 @@ func (suite *IndexTestSuite) TestIndexBehindHighID() {
|
|||
suite.NoError(err)
|
||||
suite.Equal("01FCTA44PW9H1TB328S9AQXKDS", postID)
|
||||
|
||||
// indexLength should only be 11 because that's all this user has hometimelineable
|
||||
// indexLength should be 10 because that's all this user has hometimelineable
|
||||
indexLength := suite.timeline.PostIndexLength()
|
||||
suite.Equal(11, indexLength)
|
||||
suite.Equal(10, indexLength)
|
||||
}
|
||||
|
||||
func (suite *IndexTestSuite) TestIndexBehindLowID() {
|
||||
|
|
|
|||
|
|
@ -66,9 +66,9 @@ func (suite *ManagerTestSuite) TestManagerIntegration() {
|
|||
err = suite.manager.PrepareXFromTop(testAccount.ID, 20)
|
||||
suite.NoError(err)
|
||||
|
||||
// local_account_1 can see 11 statuses out of the testrig statuses in its home timeline
|
||||
// local_account_1 can see 12 statuses out of the testrig statuses in its home timeline
|
||||
indexedLen = suite.manager.GetIndexedLength(testAccount.ID)
|
||||
suite.Equal(11, indexedLen)
|
||||
suite.Equal(12, indexedLen)
|
||||
|
||||
// oldest should now be set
|
||||
oldestIndexed, err = suite.manager.GetOldestIndexedID(testAccount.ID)
|
||||
|
|
@ -78,7 +78,7 @@ func (suite *ManagerTestSuite) TestManagerIntegration() {
|
|||
// get hometimeline
|
||||
statuses, err := suite.manager.HomeTimeline(testAccount.ID, "", "", "", 20, false)
|
||||
suite.NoError(err)
|
||||
suite.Len(statuses, 11)
|
||||
suite.Len(statuses, 12)
|
||||
|
||||
// now wipe the last status from all timelines, as though it had been deleted by the owner
|
||||
err = suite.manager.WipeStatusFromAllTimelines("01F8MH75CBF9JFX4ZAD54N0W0R")
|
||||
|
|
@ -86,7 +86,7 @@ func (suite *ManagerTestSuite) TestManagerIntegration() {
|
|||
|
||||
// timeline should be shorter
|
||||
indexedLen = suite.manager.GetIndexedLength(testAccount.ID)
|
||||
suite.Equal(10, indexedLen)
|
||||
suite.Equal(11, indexedLen)
|
||||
|
||||
// oldest should now be different
|
||||
oldestIndexed, err = suite.manager.GetOldestIndexedID(testAccount.ID)
|
||||
|
|
@ -100,7 +100,7 @@ func (suite *ManagerTestSuite) TestManagerIntegration() {
|
|||
|
||||
// timeline should be shorter
|
||||
indexedLen = suite.manager.GetIndexedLength(testAccount.ID)
|
||||
suite.Equal(9, indexedLen)
|
||||
suite.Equal(10, indexedLen)
|
||||
|
||||
// oldest should now be different
|
||||
oldestIndexed, err = suite.manager.GetOldestIndexedID(testAccount.ID)
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ prepareloop:
|
|||
if preparing {
|
||||
if err := t.prepare(entry.statusID); err != nil {
|
||||
// there's been an error
|
||||
if _, ok := err.(db.ErrNoEntries); !ok {
|
||||
if err != db.ErrNoEntries {
|
||||
// it's a real error
|
||||
return fmt.Errorf("PrepareBehind: error preparing status with id %s: %s", entry.statusID, err)
|
||||
}
|
||||
|
|
@ -150,7 +150,7 @@ prepareloop:
|
|||
if preparing {
|
||||
if err := t.prepare(entry.statusID); err != nil {
|
||||
// there's been an error
|
||||
if _, ok := err.(db.ErrNoEntries); !ok {
|
||||
if err != db.ErrNoEntries {
|
||||
// it's a real error
|
||||
return fmt.Errorf("PrepareBefore: error preparing status with id %s: %s", entry.statusID, err)
|
||||
}
|
||||
|
|
@ -205,7 +205,7 @@ prepareloop:
|
|||
|
||||
if err := t.prepare(entry.statusID); err != nil {
|
||||
// there's been an error
|
||||
if _, ok := err.(db.ErrNoEntries); !ok {
|
||||
if err != db.ErrNoEntries {
|
||||
// it's a real error
|
||||
return fmt.Errorf("PrepareFromTop: error preparing status with id %s: %s", entry.statusID, err)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue