HistoryRedisManager.coffee 720 B

12345678910111213
  1. Settings = require('settings-sharelatex')
  2. rclient = require("redis-sharelatex").createClient(Settings.redis.history)
  3. Keys = Settings.redis.history.key_schema
  4. logger = require('logger-sharelatex')
  5. module.exports = HistoryRedisManager =
  6. recordDocHasHistoryOps: (project_id, doc_id, ops = [], callback = (error) ->) ->
  7. if ops.length == 0
  8. 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
  9. logger.log project_id: project_id, doc_id: doc_id, "marking doc in project for history ops"
  10. rclient.sadd Keys.docsWithHistoryOps({project_id}), doc_id, (error) ->
  11. return callback(error) if error?
  12. callback()