From 8ac8437e91cbce921cb7245d44f5191c1916b170 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Wed, 23 Apr 2014 11:32:57 -0700 Subject: [PATCH] index: add temporary hack for foursquare.com checkin times Change-Id: Ia90097998ccb702b14c4634bb42be1e6387d61e8 --- pkg/index/corpus.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/pkg/index/corpus.go b/pkg/index/corpus.go index e8f09777b..655d2d234 100644 --- a/pkg/index/corpus.go +++ b/pkg/index/corpus.go @@ -839,6 +839,26 @@ func (c *Corpus) PermanodeModtimeLocked(pn blob.Ref) (t time.Time, ok bool) { if !ok { return } + + // TODO: this is a temporary hack. We really want the default + // search sorting mode to be created-descending, but it's + // currently modtime-descending, and all my foursquare + // checkins (thousands) are currently at the top, and not + // inter-mingled in time where they should be. This doesn't + // demo well, so hack it for now by lying about the + // modtime. This can be deleted (or at least moved to its + // proper place) when I finish the other TODOs about changing + // the default search. + nodeType := c.PermanodeAttrValueLocked(pn, "camliNodeType", time.Time{}, blob.Ref{}) + if nodeType == "foursquare.com:checkin" { + if timeStr := c.PermanodeAttrValueLocked(pn, "startDate", time.Time{}, blob.Ref{}); timeStr != "" { + t, err := time.Parse(time.RFC3339, timeStr) + if err == nil { + return t, true + } + } + } + // Note: We intentionally don't try to derive any information // (except the owner, elsewhere) from the permanode blob // itself. Even though the permanode blob sometimes has the