diff options
| author | 2025-03-10 13:52:19 +0100 | |
|---|---|---|
| committer | 2025-03-10 13:52:19 +0100 | |
| commit | 0c72282559fffa06e533de9eed375c9130c0e7a3 (patch) | |
| tree | 93b068140df095b8d92cd7ce0ff4a3402b41969a /internal/db/bundb/timeline_test.go | |
| parent | [docs/zh] update zh docs: synced to 98c4cae + fix typo (#3884) (diff) | |
| download | gotosocial-0c72282559fffa06e533de9eed375c9130c0e7a3.tar.xz | |
[performance] Optimize local timeline + local status count queries (#3892)
* [performance] Optimize local timeline + local status count queries
* remove if not exists from create view
Diffstat (limited to 'internal/db/bundb/timeline_test.go')
| -rw-r--r-- | internal/db/bundb/timeline_test.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/internal/db/bundb/timeline_test.go b/internal/db/bundb/timeline_test.go index 756ece2d4..4988ab362 100644 --- a/internal/db/bundb/timeline_test.go +++ b/internal/db/bundb/timeline_test.go @@ -79,6 +79,19 @@ func (suite *TimelineTestSuite) publicCount() int { return publicCount } +func (suite *TimelineTestSuite) localCount() int { + var localCount int + for _, status := range suite.testStatuses { + if status.Visibility == gtsmodel.VisibilityPublic && + status.BoostOfID == "" && + !util.PtrOrZero(status.PendingApproval) && + util.PtrOrValue(status.Local, true) { + localCount++ + } + } + return localCount +} + func (suite *TimelineTestSuite) checkStatuses(statuses []*gtsmodel.Status, maxID string, minID string, expectedLength int) { if l := len(statuses); l != expectedLength { suite.FailNowf("", "expected %d statuses in slice, got %d", expectedLength, l) @@ -123,6 +136,21 @@ func (suite *TimelineTestSuite) TestGetPublicTimeline() { suite.checkStatuses(s, id.Highest, id.Lowest, suite.publicCount()) } +func (suite *TimelineTestSuite) TestGetPublicTimelineLocal() { + ctx := context.Background() + + s, err := suite.db.GetPublicTimeline(ctx, "", "", "", 20, true) + if err != nil { + suite.FailNow(err.Error()) + } + + suite.T().Log(kv.Field{ + K: "statuses", V: s, + }) + + suite.checkStatuses(s, id.Highest, id.Lowest, suite.localCount()) +} + func (suite *TimelineTestSuite) TestGetPublicTimelineWithFutureStatus() { ctx := context.Background() |
