| OLD | NEW |
| 1 // Copyright 2015 The LUCI Authors. All rights reserved. | 1 // Copyright 2015 The LUCI Authors. All rights reserved. |
| 2 // Use of this source code is governed under the Apache License, Version 2.0 | 2 // Use of this source code is governed under the Apache License, Version 2.0 |
| 3 // that can be found in the LICENSE file. | 3 // that can be found in the LICENSE file. |
| 4 | 4 |
| 5 package swarming | 5 package swarming |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "bytes" | 8 "bytes" |
| 9 "encoding/json" | 9 "encoding/json" |
| 10 "fmt" | 10 "fmt" |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 } | 246 } |
| 247 | 247 |
| 248 var err error | 248 var err error |
| 249 if sr.StartedTs != "" { | 249 if sr.StartedTs != "" { |
| 250 build.Summary.Started, err = time.Parse(SwarmingTimeLayout, sr.S
tartedTs) | 250 build.Summary.Started, err = time.Parse(SwarmingTimeLayout, sr.S
tartedTs) |
| 251 if err != nil { | 251 if err != nil { |
| 252 return nil, fmt.Errorf("invalid task StartedTs: %s", err
) | 252 return nil, fmt.Errorf("invalid task StartedTs: %s", err
) |
| 253 } | 253 } |
| 254 } | 254 } |
| 255 if sr.CompletedTs != "" { | 255 if sr.CompletedTs != "" { |
| 256 » » build.Summary.Finished, err = time.Parse(SwarmingTimeLayout, sr.
StartedTs) | 256 » » build.Summary.Finished, err = time.Parse(SwarmingTimeLayout, sr.
CompletedTs) |
| 257 if err != nil { | 257 if err != nil { |
| 258 return nil, fmt.Errorf("invalid task CompletedTs: %s", e
rr) | 258 return nil, fmt.Errorf("invalid task CompletedTs: %s", e
rr) |
| 259 } | 259 } |
| 260 } | 260 } |
| 261 if sr.Duration != 0 { | 261 if sr.Duration != 0 { |
| 262 build.Summary.Duration = time.Duration(sr.Duration * float64(tim
e.Second)) | 262 build.Summary.Duration = time.Duration(sr.Duration * float64(tim
e.Second)) |
| 263 } else if sr.State == TaskRunning { | 263 } else if sr.State == TaskRunning { |
| 264 now := clock.Now(c) | 264 now := clock.Now(c) |
| 265 if build.Summary.Started.Before(now) { | 265 if build.Summary.Started.Before(now) { |
| 266 build.Summary.Duration = now.Sub(build.Summary.Started) | 266 build.Summary.Duration = now.Sub(build.Summary.Started) |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 // Supports server aliases. | 346 // Supports server aliases. |
| 347 func taskPageURL(swarmingHostname, taskID string) string { | 347 func taskPageURL(swarmingHostname, taskID string) string { |
| 348 return fmt.Sprintf("https://%s/user/task/%s", swarmingHostname, taskID) | 348 return fmt.Sprintf("https://%s/user/task/%s", swarmingHostname, taskID) |
| 349 } | 349 } |
| 350 | 350 |
| 351 // botPageURL returns a URL to a human-consumable page of a swarming bot. | 351 // botPageURL returns a URL to a human-consumable page of a swarming bot. |
| 352 // Supports server aliases. | 352 // Supports server aliases. |
| 353 func botPageURL(swarmingHostname, botID string) string { | 353 func botPageURL(swarmingHostname, botID string) string { |
| 354 return fmt.Sprintf("https://%s/restricted/bot/%s", swarmingHostname, bot
ID) | 354 return fmt.Sprintf("https://%s/restricted/bot/%s", swarmingHostname, bot
ID) |
| 355 } | 355 } |
| OLD | NEW |