1
0
Fork 0
mirror of https://github.com/overleaf/overleaf.git synced 2025-04-11 09:54:02 +00:00

script to pack existing docs

This commit is contained in:
Brian Gough 2016-01-27 15:14:23 +00:00
parent ba0de92081
commit 199d2aaa92
4 changed files with 22 additions and 0 deletions

View file

@ -49,6 +49,7 @@ app.post "/project/:project_id/flush", HttpController.flushProject
app.post "/project/:project_id/doc/:doc_id/version/:version/restore", HttpController.restore
app.post "/doc/:doc_id/pack", HttpController.packDoc
app.get "/doc/list", HttpController.listDocs
app.post '/project/:project_id/archive', HttpController.archiveProject
app.post '/project/:project_id/unarchive', HttpController.unArchiveProject

View file

@ -6,6 +6,7 @@ logger = require "logger-sharelatex"
DocArchiveManager = require "./DocArchiveManager"
HealthChecker = require "./HealthChecker"
LockManager = require "./LockManager"
_ = require "underscore"
module.exports = HttpController =
flushDoc: (req, res, next = (error) ->) ->
@ -23,6 +24,15 @@ module.exports = HttpController =
return next(error) if error?
res.send 204
listDocs: (req, res, next = (error) ->) ->
logger.log "listing packing doc history"
limit = +req.query?.limit || 100
PackManager.listDocs {limit}, (error, doc_ids) ->
return next(error) if error?
ids = (doc.doc_id.toString() for doc in doc_ids)
output = _.uniq(ids).join("\n") + "\n"
res.send output
packDoc: (req, res, next = (error) ->) ->
doc_id = req.params.doc_id
logger.log doc_id: doc_id, "packing doc history"

View file

@ -532,3 +532,7 @@ module.exports = PackManager =
logger.log {project_id, doc_id, lastUpdate, newUpdates}, "appending updates to existing pack"
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) ->
return callback(err) if err?
callback(null, docs)

7
services/track-changes/pack.sh Executable file
View file

@ -0,0 +1,7 @@
while docs=$(curl "localhost:3015/doc/list?limit=1000"); do
if [ -z "$docs" ] ; then break ; fi
for d in $docs ; do
echo "packing $d"
curl -X POST "localhost:3015/doc/$d/pack"
done
done