Commit a1da8b80 by jimabramson

fix 2 bugs in comment sort key creation

parent 113dfb91
......@@ -23,7 +23,7 @@ class Comment < Content
def set_sk()
# this attribute is explicitly write-once
if self.sk.nil?
self.sk = (self.parent_ids << self.id).join("-")
self.sk = (self.parent_ids.dup << self.id).join("-")
end
end
......
......@@ -31,10 +31,10 @@ db.contents.find({"_type":"Comment","sk":{$exists:false}}).forEach(function (doc
if (typeof(doc.parent_ids)==="undefined") {
sort_ids = [];
} else {
sort_ids = doc.parent_ids;
sort_ids = doc.parent_ids.slice(0);
}
sort_ids.push(doc._id);
doc.sk = sort_ids.join("-");
doc.sk = sort_ids.map(function (oid) {return oid.str}).join("-");
db.contents.save(doc);
}
cnt += 1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment