Use db.ListOptions directly instead of Paginator interface to make iteasier to use and fix performance of /pulls and /issues (#29990) (#30447)

backport #29990

This PR uses `db.ListOptions` instead of `Paginor` to make the code
simpler.
And it also fixed the performance problem when viewing /pulls or
/issues. Before the counting in fact will also do the search.

Co-authored-by: Jason Song <i@wolfogre.com>
Co-authored-by: silverwind <me@silverwind.io>
This commit is contained in:
Lunny Xiao
2024-04-13 17:44:57 +00:00
committed by GitHub
co-authored by Jason Song silverwind
parent fc4e08f804
commit 09df5c9c7d
8 changed files with 49 additions and 34 deletions
+1 -1
View File
@@ -104,7 +104,7 @@ type SearchOptions struct {
UpdatedAfterUnix *int64
UpdatedBeforeUnix *int64
db.Paginator
Paginator *db.ListOptions
SortBy SortBy // sort by field
}
@@ -77,6 +77,13 @@ func TestIndexer(t *testing.T, indexer internal.Indexer) {
assert.Equal(t, c.ExpectedIDs, ids)
assert.Equal(t, c.ExpectedTotal, result.Total)
}
// test counting
c.SearchOptions.Paginator = &db.ListOptions{PageSize: 0}
countResult, err := indexer.Search(context.Background(), c.SearchOptions)
require.NoError(t, err)
assert.Empty(t, countResult.Hits)
assert.Equal(t, result.Total, countResult.Total)
})
}
}