diff --git a/services/track-changes/app/coffee/HttpController.coffee b/services/track-changes/app/coffee/HttpController.coffee index 2d01d9b52c..0b4cd658e9 100644 --- a/services/track-changes/app/coffee/HttpController.coffee +++ b/services/track-changes/app/coffee/HttpController.coffee @@ -26,7 +26,8 @@ module.exports = HttpController = listDocs: (req, res, next = (error) ->) -> logger.log "listing packing doc history" limit = +req.query?.limit || 100 - PackManager.listDocs {limit}, (error, doc_ids) -> + doc_id = req.query?.doc_id if req.query?.doc_id?.match(/^[0-9a-f]{24}$/) + PackManager.listDocs {limit, doc_id}, (error, doc_ids) -> return next(error) if error? ids = (doc.doc_id.toString() for doc in doc_ids) output = _.uniq(ids).join("\n") + "\n" diff --git a/services/track-changes/app/coffee/PackManager.coffee b/services/track-changes/app/coffee/PackManager.coffee index 2c877f4a0c..7d39c43c8d 100644 --- a/services/track-changes/app/coffee/PackManager.coffee +++ b/services/track-changes/app/coffee/PackManager.coffee @@ -533,6 +533,8 @@ module.exports = PackManager = db.docHistory.findAndModify {query, update}, callback listDocs: (options, callback) -> - db.docHistory.find({"op.p":{$exists:true}}, {doc_id:true}).limit (options.limit||100), (err, docs) -> + query = {"op.p":{$exists:true}} + query.doc_id = {$gt: ObjectId(options.doc_id)} if options.doc_id? + db.docHistory.find(query, {doc_id:true}).sort({doc_id:1}).limit (options.limit||100), (err, docs) -> return callback(err) if err? callback(null, docs) diff --git a/services/track-changes/pack.sh b/services/track-changes/pack.sh index f94a58d077..9a927af0ca 100755 --- a/services/track-changes/pack.sh +++ b/services/track-changes/pack.sh @@ -11,11 +11,12 @@ for n in $(seq 5 -1 1) ; do sleep 1 done -while docs=$(curl "$HOST/doc/list?limit=1000"); do +while docs=$(curl "$HOST/doc/list?limit=1000&doc_id=$last_doc"); do if [ -z "$docs" ] ; then break ; fi for d in $docs ; do echo "packing $d" curl -X POST "$HOST/doc/$d/pack" sleep $T + last_doc=$d done done