From f805ed2ba65fdcfd0b8140ed05101ede462dd6a7 Mon Sep 17 00:00:00 2001 From: Dustin Sallings Date: Sat, 21 Dec 2013 14:12:44 -0800 Subject: [PATCH] Support requesting claims as of a particular time Change-Id: I44763bc7ffc59d08e577d7bbb74a00b3c798206d --- pkg/search/handler.go | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/pkg/search/handler.go b/pkg/search/handler.go index b6f03c253..b9776721f 100644 --- a/pkg/search/handler.go +++ b/pkg/search/handler.go @@ -655,6 +655,12 @@ type DescribeRequest struct { // directory. If zero, a default is used. MaxDirChildren int + // At specifies the time which we wish to see the state of + // this blob. If zero (unspecified), all claims will be + // considered, otherwise, any claims after this date will not + // be considered. + At types.Time3339 + ThumbnailSize int // or zero for none // Internal details, used while loading. @@ -670,7 +676,8 @@ type DescribeRequest struct { func (r *DescribeRequest) URLSuffix() string { var buf bytes.Buffer - fmt.Fprintf(&buf, "camli/search/describe?depth=%d&maxdirchildren=%d", r.depth(), r.maxDirChildren()) + fmt.Fprintf(&buf, "camli/search/describe?depth=%d&maxdirchildren=%d", + r.depth(), r.maxDirChildren()) for _, br := range r.BlobRefs { buf.WriteString("&blobref=") buf.WriteString(br.String()) @@ -679,6 +686,10 @@ func (r *DescribeRequest) URLSuffix() string { buf.WriteString("&blobref=") buf.WriteString(r.BlobRef.String()) } + if !r.At.IsZero() { + buf.WriteString("&at=") + buf.WriteString(r.At.String()) + } return buf.String() } @@ -699,6 +710,7 @@ func (r *DescribeRequest) fromHTTP(req *http.Request) { r.Depth = httputil.OptionalInt(req, "depth") r.MaxDirChildren = httputil.OptionalInt(req, "maxdirchildren") r.ThumbnailSize = thumbnailSize(req) + r.At = types.ParseTime3339OrZero(req.FormValue("at")) } type DescribedBlob struct { @@ -1292,6 +1304,11 @@ func (dr *DescribeRequest) populatePermanodeFields(pi *DescribedPermanode, pn, s sort.Sort(camtypes.ClaimsByDate(claims)) claimLoop: for _, cl := range claims { + if !dr.At.IsZero() { + if cl.Date.After(dr.At.Time()) { + continue + } + } switch cl.Type { default: continue