overleaf/services/track-changes/app/coffee/DocArchiveManager.coffee
2015-08-06 15:46:44 -03:00

27 lines
No EOL
893 B
CoffeeScript

MongoManager = require "./MongoManager"
MongoAWS = require "./MongoAWS"
logger = require "logger-sharelatex"
_ = require "underscore"
async = require "async"
settings = require("settings-sharelatex")
request = require("request")
crypto = require("crypto")
thirtySeconds = 30 * 1000
module.exports = DocArchiveManager =
archiveAllDocsChanges: (project_id, callback = (error, docs) ->) ->
MongoManager.getProjectsDocs project_id, (error, docs) ->
if error?
return callback(error)
else if !docs?
return callback new Error("No docs for project #{project_id}")
jobs = _.map docs, (doc) ->
(cb)-> DocArchiveManager.archiveDocChanges project_id, doc._id, cb
async.series jobs, callback
archiveDocChanges: (project_id, doc_id, callback)->
MongoAWS.archiveDocHistory project_id, doc_id, (error) ->
logger.log doc_id:doc_id, error: error, "mongoexport"
callback()