setResultContinue sets res.Continue if q is suitable for having a continue token. The corpus is locked for reads.
(corpus *index.Corpus, res *SearchResult)
| 1355 | // setResultContinue sets res.Continue if q is suitable for having a continue token. |
| 1356 | // The corpus is locked for reads. |
| 1357 | func (q *SearchQuery) setResultContinue(corpus *index.Corpus, res *SearchResult) { |
| 1358 | if !q.Constraint.onlyMatchesPermanode() { |
| 1359 | return |
| 1360 | } |
| 1361 | var pnTimeFunc func(blob.Ref) (t time.Time, ok bool) |
| 1362 | switch q.Sort { |
| 1363 | case LastModifiedDesc: |
| 1364 | pnTimeFunc = corpus.PermanodeModtime |
| 1365 | case CreatedDesc: |
| 1366 | pnTimeFunc = corpus.PermanodeAnyTime |
| 1367 | default: |
| 1368 | return |
| 1369 | } |
| 1370 | |
| 1371 | if q.Limit <= 0 || len(res.Blobs) != q.Limit { |
| 1372 | return |
| 1373 | } |
| 1374 | lastpn := res.Blobs[len(res.Blobs)-1].Blob |
| 1375 | t, ok := pnTimeFunc(lastpn) |
| 1376 | if !ok { |
| 1377 | return |
| 1378 | } |
| 1379 | res.Continue = fmt.Sprintf("pn:%d:%v", t.UnixNano(), lastpn) |
| 1380 | } |
| 1381 | |
| 1382 | type matchFn func(context.Context, *search, blob.Ref, camtypes.BlobMeta) (bool, error) |
| 1383 |
no test coverage detected