change update to projectUpdate in project related methods

This commit is contained in:
Brian Gough 2018-03-16 10:54:12 +00:00
parent 779f00f912
commit dd0f8b880a
2 changed files with 33 additions and 33 deletions

View file

@ -7,49 +7,49 @@ module.exports = ProjectHistoryRedisManager =
queueOps: (project_id, ops..., callback) ->
rclient.rpush projectHistoryKeys.projectHistoryOps({project_id}), ops..., callback
queueRenameEntity: (project_id, entity_type, entity_id, user_id, update, callback) ->
update =
pathname: update.pathname
new_pathname: update.newPathname
queueRenameEntity: (project_id, entity_type, entity_id, user_id, projectUpdate, callback) ->
projectUpdate =
pathname: projectUpdate.pathname
new_pathname: projectUpdate.newPathname
meta:
user_id: user_id
ts: new Date()
version: update.version
update[entity_type] = entity_id
version: projectUpdate.version
projectUpdate[entity_type] = entity_id
logger.log {project_id, update}, "queue rename operation to project-history"
jsonUpdate = JSON.stringify(update)
logger.log {project_id, projectUpdate}, "queue rename operation to project-history"
jsonUpdate = JSON.stringify(projectUpdate)
ProjectHistoryRedisManager.queueOps project_id, jsonUpdate, callback
queueAddEntity: (project_id, entity_type, entitiy_id, user_id, update, callback = (error) ->) ->
update =
pathname: update.pathname
docLines: update.docLines
url: update.url
queueAddEntity: (project_id, entity_type, entitiy_id, user_id, projectUpdate, callback = (error) ->) ->
projectUpdate =
pathname: projectUpdate.pathname
docLines: projectUpdate.docLines
url: projectUpdate.url
meta:
user_id: user_id
ts: new Date()
version: update.version
update[entity_type] = entitiy_id
version: projectUpdate.version
projectUpdate[entity_type] = entitiy_id
logger.log {project_id, update}, "queue add operation to project-history"
jsonUpdate = JSON.stringify(update)
logger.log {project_id, projectUpdate}, "queue add operation to project-history"
jsonUpdate = JSON.stringify(projectUpdate)
ProjectHistoryRedisManager.queueOps project_id, jsonUpdate, callback
queueResyncProjectStructure: (project_id, docs, files, callback) ->
logger.log {project_id, docs, files}, "queue project structure resync"
update =
projectUpdate =
resyncProjectStructure: { docs, files }
meta:
ts: new Date()
jsonUpdate = JSON.stringify update
jsonUpdate = JSON.stringify projectUpdate
ProjectHistoryRedisManager.queueOps project_id, jsonUpdate, callback
queueResyncDocContent: (project_id, doc_id, lines, version, pathname, callback) ->
logger.log {project_id, doc_id, lines, version, pathname}, "queue doc content resync"
update =
projectUpdate =
resyncDocContent:
content: lines.join("\n"),
version: version
@ -57,5 +57,5 @@ module.exports = ProjectHistoryRedisManager =
doc: doc_id
meta:
ts: new Date()
jsonUpdate = JSON.stringify update
jsonUpdate = JSON.stringify projectUpdate
ProjectHistoryRedisManager.queueOps project_id, jsonUpdate, callback

View file

@ -116,27 +116,27 @@ module.exports = ProjectManager =
project_ops_length = 0
handleDocUpdate = (update, cb) ->
doc_id = update.id
update.version = "#{project_version}.#{project_subversion++}"
if update.docLines?
ProjectHistoryRedisManager.queueAddEntity project_id, 'doc', doc_id, user_id, update, (error, count) ->
handleDocUpdate = (projectUpdate, cb) ->
doc_id = projectUpdate.id
projectUpdate.version = "#{project_version}.#{project_subversion++}"
if projectUpdate.docLines?
ProjectHistoryRedisManager.queueAddEntity project_id, 'doc', doc_id, user_id, projectUpdate, (error, count) ->
project_ops_length = count
cb(error)
else
DocumentManager.renameDocWithLock project_id, doc_id, user_id, update, (error, count) ->
DocumentManager.renameDocWithLock project_id, doc_id, user_id, projectUpdate, (error, count) ->
project_ops_length = count
cb(error)
handleFileUpdate = (update, cb) ->
file_id = update.id
update.version = "#{project_version}.#{project_subversion++}"
if update.url?
ProjectHistoryRedisManager.queueAddEntity project_id, 'file', file_id, user_id, update, (error, count) ->
handleFileUpdate = (projectUpdate, cb) ->
file_id = projectUpdate.id
projectUpdate.version = "#{project_version}.#{project_subversion++}"
if projectUpdate.url?
ProjectHistoryRedisManager.queueAddEntity project_id, 'file', file_id, user_id, projectUpdate, (error, count) ->
project_ops_length = count
cb(error)
else
ProjectHistoryRedisManager.queueRenameEntity project_id, 'file', file_id, user_id, update, (error, count) ->
ProjectHistoryRedisManager.queueRenameEntity project_id, 'file', file_id, user_id, projectUpdate, (error, count) ->
project_ops_length = count
cb(error)