OLD | NEW |
1 package frontend | 1 package frontend |
2 | 2 |
3 import ( | 3 import ( |
4 "bytes" | 4 "bytes" |
5 "encoding/json" | 5 "encoding/json" |
6 "fmt" | 6 "fmt" |
7 "infra/appengine/test-results/model" | 7 "infra/appengine/test-results/model" |
8 "io" | 8 "io" |
9 "net/http" | 9 "net/http" |
10 "regexp" | 10 "regexp" |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 http.Error(w, err.Error(), http.StatusInternalServerErro
r) | 214 http.Error(w, err.Error(), http.StatusInternalServerErro
r) |
215 logging.Errorf(c, "failed to clean test results JSON: %v
", err) | 215 logging.Errorf(c, "failed to clean test results JSON: %v
", err) |
216 return | 216 return |
217 } | 217 } |
218 aggr := model.AggregateResult{Builder: params.Builder} | 218 aggr := model.AggregateResult{Builder: params.Builder} |
219 if err := json.NewDecoder(data).Decode(&aggr); err != nil { | 219 if err := json.NewDecoder(data).Decode(&aggr); err != nil { |
220 http.Error(w, err.Error(), http.StatusInternalServerErro
r) | 220 http.Error(w, err.Error(), http.StatusInternalServerErro
r) |
221 logging.Errorf(c, "failed to unmarshal test results JSON
: %+v: %v", data, err) | 221 logging.Errorf(c, "failed to unmarshal test results JSON
: %+v: %v", data, err) |
222 return | 222 return |
223 } | 223 } |
224 » » aggr.Tests.ToTestList() | 224 » » tl := aggr.ToTestList() |
225 buf := &bytes.Buffer{} | 225 buf := &bytes.Buffer{} |
226 » » if err := json.NewEncoder(buf).Encode(aggr.Tests); err != nil { | 226 » » if err := json.NewEncoder(buf).Encode(&tl); err != nil { |
227 http.Error(w, err.Error(), http.StatusInternalServerErro
r) | 227 http.Error(w, err.Error(), http.StatusInternalServerErro
r) |
228 logging.Errorf(c, "failed to marshal test list JSON: %+v
, %v", aggr.Tests, err) | 228 logging.Errorf(c, "failed to marshal test list JSON: %+v
, %v", aggr.Tests, err) |
229 return | 229 return |
230 } | 230 } |
231 finalData = buf | 231 finalData = buf |
232 } | 232 } |
233 | 233 |
234 respondJSON(c, w, finalData, tf.LastMod, params.Callback) | 234 respondJSON(c, w, finalData, tf.LastMod, params.Callback) |
235 } | 235 } |
236 | 236 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 } | 273 } |
274 } | 274 } |
275 | 275 |
276 // wrapCallback returns an io.Reader that wraps the data in r in a | 276 // wrapCallback returns an io.Reader that wraps the data in r in a |
277 // JavaScript-style function call with the supplied name as the function name. | 277 // JavaScript-style function call with the supplied name as the function name. |
278 func wrapCallback(r io.Reader, name string) io.Reader { | 278 func wrapCallback(r io.Reader, name string) io.Reader { |
279 start := bytes.NewReader([]byte(name + "(")) | 279 start := bytes.NewReader([]byte(name + "(")) |
280 end := bytes.NewReader([]byte(");")) | 280 end := bytes.NewReader([]byte(");")) |
281 return io.MultiReader(start, r, end) | 281 return io.MultiReader(start, r, end) |
282 } | 282 } |
OLD | NEW |