mirror of
https://github.com/samsonjs/retrogit.git
synced 2026-03-25 09:25:49 +00:00
Add chunking for looking of repo vintages.
Can only call datastore.GetMulti with 1000 keys.
This commit is contained in:
parent
012d736e25
commit
535a3b2acf
1 changed files with 14 additions and 0 deletions
14
app/repos.go
14
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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue