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

Unified Diff: go/buildbucket/buildbucket.go

Issue 2226583003: Add build scheduler DB interface, dumb in-memory impl, cache (Closed) Base URL: https://skia.googlesource.com/buildbot@master
Patch Set: Address more comments 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « build_scheduler/go/db/memory.go ('k') | go/testutils/testutils.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: go/buildbucket/buildbucket.go
diff --git a/go/buildbucket/buildbucket.go b/go/buildbucket/buildbucket.go
index 050d767fa1bceb8850b245b1454e9b92ac12f6be..76595456be8456c43c7d4857166719af1f82daca 100644
--- a/go/buildbucket/buildbucket.go
+++ b/go/buildbucket/buildbucket.go
@@ -7,6 +7,8 @@ import (
"fmt"
"io/ioutil"
"net/http"
+ "strconv"
+ "time"
"go.skia.org/infra/go/util"
)
@@ -67,6 +69,49 @@ type Build struct {
UtcNowTimestamp string `json:"utcnow_ts"`
}
+func (b *Build) Copy() *Build {
+ return &Build{
+ Bucket: b.Bucket,
+ CompletedTimestamp: b.CompletedTimestamp,
+ CreatedBy: b.CreatedBy,
+ CreatedTimestamp: b.CreatedTimestamp,
+ FailureReason: b.FailureReason,
+ Id: b.Id,
+ Url: b.Url,
+ ParametersJson: b.ParametersJson,
+ Result: b.Result,
+ ResultDetailsJson: b.ResultDetailsJson,
+ Status: b.Status,
+ StatusChangedTimestamp: b.StatusChangedTimestamp,
+ UpdatedTimestamp: b.UpdatedTimestamp,
+ UtcNowTimestamp: b.UtcNowTimestamp,
+ }
+}
+
+func parseTime(t string) (time.Time, error) {
+ i, err := strconv.ParseInt(t, 10, 64)
+ if err != nil {
+ return time.Time{}, err
+ }
+ return time.Unix(0, i), nil
+}
+
+func (b *Build) Created() (time.Time, error) {
+ return parseTime(b.CreatedTimestamp)
+}
+
+func (b *Build) Completed() (time.Time, error) {
+ return parseTime(b.CompletedTimestamp)
+}
+
+func (b *Build) StatusChanged() (time.Time, error) {
+ return parseTime(b.StatusChangedTimestamp)
+}
+
+func (b *Build) Updated() (time.Time, error) {
+ return parseTime(b.UpdatedTimestamp)
+}
+
// Client is used for interacting with the BuildBucket API.
type Client struct {
*http.Client
« no previous file with comments | « build_scheduler/go/db/memory.go ('k') | go/testutils/testutils.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698