MCPcopy Index your code
hub / github.com/git-bug/git-bug / doPaginate

Method doPaginate

termui/bug_table.go:250–277  ·  view source on GitHub ↗
(max int)

Source from the content-addressed store, hash-verified

248}
249
250func (bt *bugTable) doPaginate(max int) error {
251 // clamp the cursor
252 bt.pageCursor = maxInt(bt.pageCursor, 0)
253 bt.pageCursor = minInt(bt.pageCursor, len(bt.allIds))
254
255 nb := minInt(len(bt.allIds)-bt.pageCursor, max)
256
257 if nb < 0 {
258 bt.excerpts = []*cache.BugExcerpt{}
259 return nil
260 }
261
262 // slice the data
263 ids := bt.allIds[bt.pageCursor : bt.pageCursor+nb]
264
265 bt.excerpts = make([]*cache.BugExcerpt, len(ids))
266
267 for i, id := range ids {
268 excerpt, err := bt.repo.Bugs().ResolveExcerpt(id)
269 if err != nil {
270 return err
271 }
272
273 bt.excerpts[i] = excerpt
274 }
275
276 return nil
277}
278
279func (bt *bugTable) getTableLength() int {
280 return len(bt.excerpts)

Callers 5

paginateMethod · 0.95
cursorDownMethod · 0.95
cursorUpMethod · 0.95
nextPageMethod · 0.95
previousPageMethod · 0.95

Calls 4

maxIntFunction · 0.85
minIntFunction · 0.85
ResolveExcerptMethod · 0.80
BugsMethod · 0.80

Tested by

no test coverage detected