From 5cd8a7291c80216298861098322bb0c160d4d350 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Tue, 12 May 2020 15:10:06 -0400 Subject: [PATCH] api: references: complete cursor implementation --- api/graph/schema.resolvers.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/api/graph/schema.resolvers.go b/api/graph/schema.resolvers.go index ab0d272..b60dbfc 100644 --- a/api/graph/schema.resolvers.go +++ b/api/graph/schema.resolvers.go @@ -183,12 +183,21 @@ func (r *repositoryResolver) References(ctx context.Context, obj *model.Reposito return refs[i].Name() < refs[j].Name() }) - // TODO: Implement cursor globbing/next + if cursor.Next != "" { + i := sort.Search(len(refs), func(n int) bool { + return refs[n].Name() > cursor.Next + }) + if i != len(refs) { + refs = refs[i+1:] + } else { + refs = nil + } + } if len(refs) > cursor.Count { cursor = &model.Cursor{ Count: cursor.Count, - Next: refs[len(refs)-1].Name(), + Next: refs[cursor.Count].Name(), Search: cursor.Search, } refs = refs[:cursor.Count] -- 2.38.4