Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Side by Side Diff: go/src/infra/appengine/test-results/model/test_file.go

Issue 2240473004: test-results: package frontend: add upload handler (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Address estaab@ comments, set dependent CL Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « go/src/infra/appengine/test-results/frontend/upload_test.go ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 package model 1 package model
2 2
3 import ( 3 import (
4 "bytes" 4 "bytes"
5 "fmt" 5 "fmt"
6 "io" 6 "io"
7 "io/ioutil" 7 "io/ioutil"
8 "math" 8 "math"
9 "time" 9 "time"
10 10
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 "model: data too large %d bytes (max allowed %d bytes)", 179 "model: data too large %d bytes (max allowed %d bytes)",
180 len(data), 180 len(data),
181 maxDataEntries*maxBlobLen, 181 maxDataEntries*maxBlobLen,
182 ) 182 )
183 } 183 }
184 184
185 // Break data into chunks of max. allowed blob length. 185 // Break data into chunks of max. allowed blob length.
186 numEntries := int(math.Ceil(float64(len(data)) / maxBlobLen)) 186 numEntries := int(math.Ceil(float64(len(data)) / maxBlobLen))
187 dataEntries := make([]DataEntry, 0, numEntries) 187 dataEntries := make([]DataEntry, 0, numEntries)
188 for i := 0; i < numEntries*maxBlobLen; i += maxBlobLen { 188 for i := 0; i < numEntries*maxBlobLen; i += maxBlobLen {
189 » » dataEntries = append(dataEntries, DataEntry{Data: data[i : i+max BlobLen]}) 189 » » end := min(i+maxBlobLen, len(data))
190 » » dataEntries = append(dataEntries, DataEntry{Data: data[i:end]})
190 } 191 }
191 192
192 if err := datastore.Get(c).Put(dataEntries); err != nil { 193 if err := datastore.Get(c).Put(dataEntries); err != nil {
193 return err 194 return err
194 } 195 }
195 196
196 newKeys := make([]*datastore.Key, 0, len(dataEntries)) 197 newKeys := make([]*datastore.Key, 0, len(dataEntries))
197 for _, de := range dataEntries { 198 for _, de := range dataEntries {
198 newKeys = append(newKeys, datastore.Get(c).KeyForObj(&de)) 199 newKeys = append(newKeys, datastore.Get(c).KeyForObj(&de))
199 } 200 }
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 q = q.Order("-date") 317 q = q.Order("-date")
317 318
318 if p.Limit < 0 || p.Limit > defaultLimit { 319 if p.Limit < 0 || p.Limit > defaultLimit {
319 q = q.Limit(defaultLimit) 320 q = q.Limit(defaultLimit)
320 } else { 321 } else {
321 q = q.Limit(p.Limit) 322 q = q.Limit(p.Limit)
322 } 323 }
323 324
324 return q 325 return q
325 } 326 }
OLDNEW
« no previous file with comments | « go/src/infra/appengine/test-results/frontend/upload_test.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698