From c5cfbb7a2fc391370e460abe85e128337b0a0ec9 Mon Sep 17 00:00:00 2001 From: Jared Bischof Date: Fri, 4 Apr 2014 16:11:33 -0500 Subject: [PATCH 1/3] Added ability to query for field equal to null --- shock-server/controller/node/multi.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/shock-server/controller/node/multi.go b/shock-server/controller/node/multi.go index ad8e0e1e..400e6015 100644 --- a/shock-server/controller/node/multi.go +++ b/shock-server/controller/node/multi.go @@ -59,6 +59,8 @@ func (cr *NodeController) ReadMany(ctx context.Context) error { if value != "" { if numValue, err := strconv.Atoi(value); err == nil { q["$or"] = ListOfMaps{{keyStr: value}, {keyStr: numValue}} + } else if value == "null" { + q["$or"] = ListOfMaps{{keyStr: value}, {keyStr: nil}} } else { q[keyStr] = value } @@ -77,6 +79,8 @@ func (cr *NodeController) ReadMany(ctx context.Context) error { if value != "" { if numValue, err := strconv.Atoi(value); err == nil { q["$or"] = ListOfMaps{{key: value}, {key: numValue}} + } else if value == "null" { + q["$or"] = ListOfMaps{{key: value}, {key: nil}} } else { q[key] = value } From f3e8fcf2bee4ac37c007dde20c52f21eda6e6348 Mon Sep 17 00:00:00 2001 From: Jared Bischof Date: Fri, 4 Apr 2014 16:12:20 -0500 Subject: [PATCH 2/3] Changed date fields to actually be stored as datetime objects, rather than as strings. --- shock-server/node/node.go | 6 +++--- shock-server/node/update.go | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/shock-server/node/node.go b/shock-server/node/node.go index 3bf2478c..12e3ea68 100644 --- a/shock-server/node/node.go +++ b/shock-server/node/node.go @@ -13,6 +13,7 @@ import ( "github.com/MG-RAST/golib/mgo/bson" "io/ioutil" "os" + "time" ) type Node struct { @@ -27,8 +28,8 @@ type Node struct { Tags []string `bson:"tags" json:"tags"` Revisions []Node `bson:"revisions" json:"-"` Linkages []linkage `bson:"linkage" json:"linkages"` - CreatedOn string `bson:"created_on" json:"created_on"` - LastModified string `bson:"last_modified" json:"last_modified"` + CreatedOn time.Time `bson:"created_on" json:"created_on"` + LastModified time.Time `bson:"last_modified" json:"last_modified"` } type linkage struct { @@ -58,7 +59,6 @@ func New() (node *Node) { node.Indexes = make(map[string]IdxInfo) node.File.Checksum = make(map[string]string) node.setId() - node.LastModified = "-" return } diff --git a/shock-server/node/update.go b/shock-server/node/update.go index c19c33c8..2b9dd1ce 100644 --- a/shock-server/node/update.go +++ b/shock-server/node/update.go @@ -272,10 +272,10 @@ func (node *Node) Save() (err error) { n := Node{node.Id, node.Version, node.File, node.Attributes, node.Public, node.Indexes, node.Acl, node.VersionParts, node.Tags, nil, node.Linkages, node.CreatedOn, node.LastModified} node.Revisions = append(node.Revisions, n) } - if node.CreatedOn == "" { - node.CreatedOn = time.Now().Format(time.UnixDate) + if node.CreatedOn.String() == "" { + node.CreatedOn = time.Now() } else { - node.LastModified = time.Now().Format(time.UnixDate) + node.LastModified = time.Now() } bsonPath := fmt.Sprintf("%s/%s.bson", node.Path(), node.Id) From aeed52ce34e2f9f53a622032a0e4a10ff227d64d Mon Sep 17 00:00:00 2001 From: Jared Bischof Date: Fri, 4 Apr 2014 16:12:32 -0500 Subject: [PATCH 3/3] Updated version to 0.8.9 --- VERSION | 2 +- shock-server/main.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index 6201b5f7..55485e17 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.8.8 +0.8.9 diff --git a/shock-server/main.go b/shock-server/main.go index 5ecc8cb4..a383dd19 100644 --- a/shock-server/main.go +++ b/shock-server/main.go @@ -109,7 +109,7 @@ func mapRoutes() { R: []string{"node"}, T: "Shock", U: host + "/", - V: "0.8.8", + V: "0.8.9", } return responder.WriteResponseObject(ctx, http.StatusOK, r) })