2017-04-13 12:00:42 -04:00
Settings = require ( ' settings-sharelatex ' )
rclient = require ( " redis-sharelatex " ) . createClient ( Settings . redis . history )
Keys = Settings . redis . history . key_schema
logger = require ( ' logger-sharelatex ' )
module.exports = HistoryRedisManager =
2017-05-09 05:34:31 -04:00
recordDocHasHistoryOps: ( project_id , doc_id , ops = [ ] , callback = (error) -> ) ->
2017-04-13 12:00:42 -04:00
if ops . length == 0
return callback ( new Error ( " cannot push no ops " ) ) # This should never be called with no ops, but protect against a redis error if we sent an empty array to rpush
2018-12-13 06:03:08 -05:00
logger . info project_id: project_id , doc_id: doc_id , " marking doc in project for history ops "
2017-05-08 10:56:02 -04:00
rclient . sadd Keys . docsWithHistoryOps ( { project_id } ) , doc_id , (error) ->
2017-04-13 12:00:42 -04:00
return callback ( error ) if error ?
2017-05-09 05:34:31 -04:00
callback ( )