mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-14 10:07:33 -06:00
[bugfix/chore] Refactor timeline code (#1656)
* start poking timelines * OK yes we're refactoring, but it's nothing like the last time so don't worry * more fiddling * update tests, simplify Get * thanks linter, you're the best, mwah mwah kisses * do a bit more tidying up * start buggering about with the prepare function * fix little oopsie * start merging lists into 1 * ik heb een heel zwaar leven nee nee echt waar * hey it works we did it reddit * regenerate swagger docs * tidy up a wee bit * adjust paging * fix little error, remove unused functions
This commit is contained in:
parent
c54510bc74
commit
3510454768
22 changed files with 1319 additions and 1365 deletions
|
|
@ -72,23 +72,9 @@ func (suite *ManagerTestSuite) TestManagerIntegration() {
|
|||
suite.Equal(0, indexedLen)
|
||||
|
||||
// oldestIndexed should be empty string since there's nothing indexed
|
||||
oldestIndexed, err := suite.manager.GetOldestIndexedID(ctx, testAccount.ID)
|
||||
suite.NoError(err)
|
||||
oldestIndexed := suite.manager.GetOldestIndexedID(ctx, testAccount.ID)
|
||||
suite.Empty(oldestIndexed)
|
||||
|
||||
// trigger status preparation
|
||||
err = suite.manager.PrepareXFromTop(ctx, testAccount.ID, 20)
|
||||
suite.NoError(err)
|
||||
|
||||
// local_account_1 can see 16 statuses out of the testrig statuses in its home timeline
|
||||
indexedLen = suite.manager.GetIndexedLength(ctx, testAccount.ID)
|
||||
suite.Equal(16, indexedLen)
|
||||
|
||||
// oldest should now be set
|
||||
oldestIndexed, err = suite.manager.GetOldestIndexedID(ctx, testAccount.ID)
|
||||
suite.NoError(err)
|
||||
suite.Equal("01F8MH75CBF9JFX4ZAD54N0W0R", oldestIndexed)
|
||||
|
||||
// get hometimeline
|
||||
statuses, err := suite.manager.GetTimeline(ctx, testAccount.ID, "", "", "", 20, false)
|
||||
suite.NoError(err)
|
||||
|
|
@ -103,22 +89,20 @@ func (suite *ManagerTestSuite) TestManagerIntegration() {
|
|||
suite.Equal(15, indexedLen)
|
||||
|
||||
// oldest should now be different
|
||||
oldestIndexed, err = suite.manager.GetOldestIndexedID(ctx, testAccount.ID)
|
||||
suite.NoError(err)
|
||||
oldestIndexed = suite.manager.GetOldestIndexedID(ctx, testAccount.ID)
|
||||
suite.Equal("01F8MH82FYRXD2RC6108DAJ5HB", oldestIndexed)
|
||||
|
||||
// delete the new oldest status specifically from this timeline, as though local_account_1 had muted or blocked it
|
||||
removed, err := suite.manager.Remove(ctx, testAccount.ID, "01F8MH82FYRXD2RC6108DAJ5HB")
|
||||
suite.NoError(err)
|
||||
suite.Equal(2, removed) // 1 status should be removed, but from both indexed and prepared, so 2 removals total
|
||||
suite.Equal(1, removed) // 1 status should be removed
|
||||
|
||||
// timeline should be shorter
|
||||
indexedLen = suite.manager.GetIndexedLength(ctx, testAccount.ID)
|
||||
suite.Equal(14, indexedLen)
|
||||
|
||||
// oldest should now be different
|
||||
oldestIndexed, err = suite.manager.GetOldestIndexedID(ctx, testAccount.ID)
|
||||
suite.NoError(err)
|
||||
oldestIndexed = suite.manager.GetOldestIndexedID(ctx, testAccount.ID)
|
||||
suite.Equal("01F8MHAAY43M6RJ473VQFCVH37", oldestIndexed)
|
||||
|
||||
// now remove all entries by local_account_2 from the timeline
|
||||
|
|
@ -129,24 +113,18 @@ func (suite *ManagerTestSuite) TestManagerIntegration() {
|
|||
indexedLen = suite.manager.GetIndexedLength(ctx, testAccount.ID)
|
||||
suite.Equal(7, indexedLen)
|
||||
|
||||
// ingest 1 into the timeline
|
||||
status1 := suite.testStatuses["admin_account_status_1"]
|
||||
ingested, err := suite.manager.Ingest(ctx, status1, testAccount.ID)
|
||||
suite.NoError(err)
|
||||
suite.True(ingested)
|
||||
|
||||
// ingest and prepare another one into the timeline
|
||||
status2 := suite.testStatuses["local_account_2_status_1"]
|
||||
ingested, err = suite.manager.IngestAndPrepare(ctx, status2, testAccount.ID)
|
||||
status := suite.testStatuses["local_account_2_status_1"]
|
||||
ingested, err := suite.manager.IngestOne(ctx, testAccount.ID, status)
|
||||
suite.NoError(err)
|
||||
suite.True(ingested)
|
||||
|
||||
// timeline should be longer now
|
||||
indexedLen = suite.manager.GetIndexedLength(ctx, testAccount.ID)
|
||||
suite.Equal(9, indexedLen)
|
||||
suite.Equal(8, indexedLen)
|
||||
|
||||
// try to ingest status 2 again
|
||||
ingested, err = suite.manager.IngestAndPrepare(ctx, status2, testAccount.ID)
|
||||
// try to ingest same status again
|
||||
ingested, err = suite.manager.IngestOne(ctx, testAccount.ID, status)
|
||||
suite.NoError(err)
|
||||
suite.False(ingested) // should be false since it's a duplicate
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue