From 535a3b2acfb15c5606b3a7651b2e2d777a40f01b Mon Sep 17 00:00:00 2001 From: Mihai Parparita Date: Wed, 26 Oct 2016 23:21:00 -0700 Subject: [PATCH] Add chunking for looking of repo vintages. Can only call datastore.GetMulti with 1000 keys. --- app/repos.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/app/repos.go b/app/repos.go index d1af76b..50813d1 100644 --- a/app/repos.go +++ b/app/repos.go @@ -14,6 +14,7 @@ import ( const ( VintageDateFormat = "January 2, 2006" + VintageChunkSize = 1000 ) type RepoVintage struct { @@ -122,6 +123,19 @@ func init() { } func fillVintages(c appengine.Context, user *github.User, repos []*Repo) error { + if len(repos) > VintageChunkSize { + for chunkStart := 0; chunkStart < len(repos); chunkStart += VintageChunkSize { + chunkEnd := chunkStart + VintageChunkSize + if chunkEnd > len(repos) { + chunkEnd = len(repos) + } + err := fillVintages(c, user, repos[chunkStart:chunkEnd]) + if err != nil { + return err + } + } + return nil + } keys := make([]*datastore.Key, len(repos)) for i := range repos { keys[i] = getVintageKey(c, *user.ID, *repos[i].ID)