| OLD | NEW |
| 1 // Copyright 2016 The LUCI Authors. All rights reserved. | 1 // Copyright 2016 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 buildbucket | 5 package buildbucket |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "encoding/json" | 8 "encoding/json" |
| 9 "fmt" | 9 "fmt" |
| 10 "net/url" | 10 "net/url" |
| 11 "os" | 11 "os" |
| 12 "path" | 12 "path" |
| 13 "path/filepath" | 13 "path/filepath" |
| 14 "strconv" | 14 "strconv" |
| 15 "strings" | 15 "strings" |
| 16 "time" | 16 "time" |
| 17 | 17 |
| 18 "golang.org/x/net/context" | 18 "golang.org/x/net/context" |
| 19 "google.golang.org/api/googleapi" | 19 "google.golang.org/api/googleapi" |
| 20 | 20 |
| 21 "github.com/luci/gae/service/info" | 21 "github.com/luci/gae/service/info" |
| 22 "github.com/luci/luci-go/common/api/buildbucket/buildbucket/v1" | 22 "github.com/luci/luci-go/common/api/buildbucket/buildbucket/v1" |
| 23 "github.com/luci/luci-go/common/clock" | 23 "github.com/luci/luci-go/common/clock" |
| 24 "github.com/luci/luci-go/common/errors" | 24 "github.com/luci/luci-go/common/errors" |
| 25 "github.com/luci/luci-go/common/logging" | 25 "github.com/luci/luci-go/common/logging" |
| 26 "github.com/luci/luci-go/common/retry" | 26 "github.com/luci/luci-go/common/retry" |
| 27 "github.com/luci/luci-go/common/sync/parallel" | 27 "github.com/luci/luci-go/common/sync/parallel" |
| 28 | 28 |
| 29 "github.com/luci/luci-go/milo/api/resp" | 29 "github.com/luci/luci-go/milo/api/resp" |
| 30 » "github.com/luci/luci-go/milo/appengine/common" | 30 » "github.com/luci/luci-go/milo/common" |
| 31 » "github.com/luci/luci-go/milo/appengine/common/model" | 31 » "github.com/luci/luci-go/milo/common/model" |
| 32 ) | 32 ) |
| 33 | 33 |
| 34 // search executes the search request with retries and exponential back-off. | 34 // search executes the search request with retries and exponential back-off. |
| 35 func search(c context.Context, client *buildbucket.Service, req *buildbucket.Sea
rchCall) ( | 35 func search(c context.Context, client *buildbucket.Service, req *buildbucket.Sea
rchCall) ( |
| 36 *buildbucket.ApiSearchResponseMessage, error) { | 36 *buildbucket.ApiSearchResponseMessage, error) { |
| 37 | 37 |
| 38 var res *buildbucket.ApiSearchResponseMessage | 38 var res *buildbucket.ApiSearchResponseMessage |
| 39 err := retry.Retry( | 39 err := retry.Retry( |
| 40 c, | 40 c, |
| 41 retry.TransientOnly(retry.Default), | 41 retry.TransientOnly(retry.Default), |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 return time.Unix(microseconds/1e6, microseconds%1e6*1000).UTC() | 287 return time.Unix(microseconds/1e6, microseconds%1e6*1000).UTC() |
| 288 } | 288 } |
| 289 | 289 |
| 290 type newBuildsFirst []*resp.BuildSummary | 290 type newBuildsFirst []*resp.BuildSummary |
| 291 | 291 |
| 292 func (a newBuildsFirst) Len() int { return len(a) } | 292 func (a newBuildsFirst) Len() int { return len(a) } |
| 293 func (a newBuildsFirst) Swap(i, j int) { a[i], a[j] = a[j], a[i] } | 293 func (a newBuildsFirst) Swap(i, j int) { a[i], a[j] = a[j], a[i] } |
| 294 func (a newBuildsFirst) Less(i, j int) bool { | 294 func (a newBuildsFirst) Less(i, j int) bool { |
| 295 return a[i].PendingTime.Started.After(a[j].PendingTime.Started) | 295 return a[i].PendingTime.Started.After(a[j].PendingTime.Started) |
| 296 } | 296 } |
| OLD | NEW |