mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-29 14:13:38 -05:00
decaffeinate: Run post-processing cleanups on DiffGenerator.coffee and 17 other files
This commit is contained in:
parent
57345632e0
commit
65ecd31c3a
18 changed files with 165 additions and 49 deletions
|
@ -1,3 +1,10 @@
|
|||
/* eslint-disable
|
||||
camelcase,
|
||||
no-proto,
|
||||
no-unused-vars,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS101: Remove unnecessary use of Array.from
|
||||
|
@ -73,7 +80,7 @@ module.exports = (DiffGenerator = {
|
|||
},
|
||||
|
||||
rewindUpdates(content, updates) {
|
||||
for (let update of Array.from(updates.reverse())) {
|
||||
for (const update of Array.from(updates.reverse())) {
|
||||
try {
|
||||
content = DiffGenerator.rewindUpdate(content, update);
|
||||
} catch (e) {
|
||||
|
@ -86,7 +93,7 @@ module.exports = (DiffGenerator = {
|
|||
|
||||
buildDiff(initialContent, updates) {
|
||||
let diff = [ {u: initialContent} ];
|
||||
for (let update of Array.from(updates)) {
|
||||
for (const update of Array.from(updates)) {
|
||||
diff = DiffGenerator.applyUpdateToDiff(diff, update);
|
||||
}
|
||||
diff = DiffGenerator.compressDiff(diff);
|
||||
|
@ -95,7 +102,7 @@ module.exports = (DiffGenerator = {
|
|||
|
||||
compressDiff(diff) {
|
||||
const newDiff = [];
|
||||
for (let part of Array.from(diff)) {
|
||||
for (const part of Array.from(diff)) {
|
||||
const lastPart = newDiff[newDiff.length - 1];
|
||||
if ((lastPart != null) && ((lastPart.meta != null ? lastPart.meta.user : undefined) != null) && ((part.meta != null ? part.meta.user : undefined) != null)) {
|
||||
if ((lastPart.i != null) && (part.i != null) && (lastPart.meta.user.id === part.meta.user.id)) {
|
||||
|
@ -140,7 +147,7 @@ module.exports = (DiffGenerator = {
|
|||
},
|
||||
|
||||
applyUpdateToDiff(diff, update) {
|
||||
for (let op of Array.from(update.op)) {
|
||||
for (const op of Array.from(update.op)) {
|
||||
if (op.broken !== true) {
|
||||
diff = DiffGenerator.applyOpToDiff(diff, op, update.meta);
|
||||
}
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS101: Remove unnecessary use of Array.from
|
||||
|
@ -41,7 +47,7 @@ module.exports = (DiffManager = {
|
|||
}
|
||||
|
||||
const updatesToApply = [];
|
||||
for (let update of Array.from(updates.slice().reverse())) {
|
||||
for (const update of Array.from(updates.slice().reverse())) {
|
||||
if (update.v <= toVersion) {
|
||||
updatesToApply.push(update);
|
||||
}
|
||||
|
@ -93,7 +99,7 @@ module.exports = (DiffManager = {
|
|||
if (error != null) { return callback(error); }
|
||||
|
||||
// bail out if we hit a broken update
|
||||
for (let u of Array.from(updates)) {
|
||||
for (const u of Array.from(updates)) {
|
||||
if (u.broken) {
|
||||
return callback(new Error("broken-history"));
|
||||
}
|
||||
|
|
|
@ -1,3 +1,10 @@
|
|||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
no-unused-vars,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
/* eslint-disable
|
||||
camelcase,
|
||||
standard/no-callback-literal,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
|
|
|
@ -1,3 +1,10 @@
|
|||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
no-unused-vars,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS101: Remove unnecessary use of Array.from
|
||||
|
@ -78,8 +85,8 @@ module.exports = (HttpController = {
|
|||
return DiffManager.getDocumentBeforeVersion(project_id, doc_id, 1, function(error, document, rewoundUpdates) {
|
||||
if (error != null) { return next(error); }
|
||||
const broken = [];
|
||||
for (let update of Array.from(rewoundUpdates)) {
|
||||
for (let op of Array.from(update.op)) {
|
||||
for (const update of Array.from(rewoundUpdates)) {
|
||||
for (const op of Array.from(update.op)) {
|
||||
if (op.broken === true) {
|
||||
broken.push(op);
|
||||
}
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
/* eslint-disable
|
||||
handle-callback-err,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
|
|
|
@ -1,3 +1,11 @@
|
|||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
no-return-assign,
|
||||
no-unused-vars,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS101: Remove unnecessary use of Array.from
|
||||
|
@ -119,7 +127,7 @@ module.exports = (MongoAWS = {
|
|||
object._id = ObjectId(object._id);
|
||||
object.doc_id = ObjectId(object.doc_id);
|
||||
object.project_id = ObjectId(object.project_id);
|
||||
for (let op of Array.from(object.pack)) {
|
||||
for (const op of Array.from(object.pack)) {
|
||||
if (op._id != null) { op._id = ObjectId(op._id); }
|
||||
}
|
||||
return callback(null, object);
|
||||
|
|
|
@ -1,3 +1,10 @@
|
|||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
no-unused-vars,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
|
|
|
@ -1,3 +1,10 @@
|
|||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
no-unused-vars,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS101: Remove unnecessary use of Array.from
|
||||
|
@ -191,23 +198,23 @@ module.exports = (PackManager = {
|
|||
const query = {doc_id:ObjectId(doc_id.toString())};
|
||||
if (toVersion != null) { query.v = {$lte:toVersion}; }
|
||||
if (fromVersion != null) { query.v_end = {$gte:fromVersion}; }
|
||||
//console.log "query:", query
|
||||
// console.log "query:", query
|
||||
return db.docHistory.find(query).sort({v:-1}, function(err, result) {
|
||||
if (err != null) { return callback(err); }
|
||||
//console.log "getOpsByVersionRange:", err, result
|
||||
// console.log "getOpsByVersionRange:", err, result
|
||||
const updates = [];
|
||||
const opInRange = function(op, from, to) {
|
||||
if ((fromVersion != null) && (op.v < fromVersion)) { return false; }
|
||||
if ((toVersion != null) && (op.v > toVersion)) { return false; }
|
||||
return true;
|
||||
};
|
||||
for (let docHistory of Array.from(result)) {
|
||||
//console.log 'adding', docHistory.pack
|
||||
for (let op of Array.from(docHistory.pack.reverse())) {
|
||||
for (const docHistory of Array.from(result)) {
|
||||
// console.log 'adding', docHistory.pack
|
||||
for (const op of Array.from(docHistory.pack.reverse())) {
|
||||
if (opInRange(op, fromVersion, toVersion)) {
|
||||
op.project_id = docHistory.project_id;
|
||||
op.doc_id = docHistory.doc_id;
|
||||
//console.log "added op", op.v, fromVersion, toVersion
|
||||
// console.log "added op", op.v, fromVersion, toVersion
|
||||
updates.push(op);
|
||||
}
|
||||
}
|
||||
|
@ -286,7 +293,7 @@ module.exports = (PackManager = {
|
|||
}
|
||||
return db.docHistoryIndex.find({project_id: ObjectId(project_id)}, function(err, indexes) {
|
||||
if (err != null) { return callback(err); }
|
||||
for (let index of Array.from(indexes)) {
|
||||
for (const index of Array.from(indexes)) {
|
||||
for (pack of Array.from(index.packs)) {
|
||||
if (!seenIds[pack._id]) {
|
||||
pack.project_id = index.project_id;
|
||||
|
@ -353,7 +360,7 @@ module.exports = (PackManager = {
|
|||
return PackManager.getIndex(doc_id, function(err, index) {
|
||||
if (err != null) { return callback(err); }
|
||||
if ((index == null)) { return callback(); }
|
||||
for (let pack of Array.from((index != null ? index.packs : undefined) || [])) {
|
||||
for (const pack of Array.from((index != null ? index.packs : undefined) || [])) {
|
||||
index[pack._id] = pack;
|
||||
}
|
||||
return callback(null, index);
|
||||
|
@ -362,7 +369,7 @@ module.exports = (PackManager = {
|
|||
|
||||
initialiseIndex(project_id, doc_id, callback) {
|
||||
return PackManager.findCompletedPacks(project_id, doc_id, function(err, packs) {
|
||||
//console.log 'err', err, 'packs', packs, packs?.length
|
||||
// console.log 'err', err, 'packs', packs, packs?.length
|
||||
if (err != null) { return callback(err); }
|
||||
if ((packs == null)) { return callback(); }
|
||||
return PackManager.insertPacksIntoIndexWithLock(project_id, doc_id, packs, callback);
|
||||
|
@ -492,7 +499,7 @@ module.exports = (PackManager = {
|
|||
delete result.last_checked;
|
||||
delete pack.last_checked;
|
||||
// need to compare ids as ObjectIds with .equals()
|
||||
for (let key of ['_id', 'project_id', 'doc_id']) {
|
||||
for (const key of ['_id', 'project_id', 'doc_id']) {
|
||||
if (result[key].equals(pack[key])) { result[key] = pack[key]; }
|
||||
}
|
||||
for (let i = 0; i < result.pack.length; i++) {
|
||||
|
@ -621,7 +628,7 @@ module.exports = (PackManager = {
|
|||
const indexPacks = (indexResult != null ? indexResult.packs : undefined) || [];
|
||||
const unArchivedPacks = ((() => {
|
||||
const result = [];
|
||||
for (let pack of Array.from(indexPacks)) { if ((pack.inS3 == null)) {
|
||||
for (const pack of Array.from(indexPacks)) { if ((pack.inS3 == null)) {
|
||||
result.push(pack);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
/* eslint-disable
|
||||
camelcase,
|
||||
no-unused-vars,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS101: Remove unnecessary use of Array.from
|
||||
|
@ -40,7 +46,7 @@ if (!source.match(/^[0-9]+$/)) {
|
|||
const file = fs.readFileSync(source);
|
||||
const result = (() => {
|
||||
const result1 = [];
|
||||
for (let line of Array.from(file.toString().split('\n'))) {
|
||||
for (const line of Array.from(file.toString().split('\n'))) {
|
||||
[project_id, doc_id] = Array.from(line.split(' '));
|
||||
result1.push({doc_id, project_id});
|
||||
}
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
/* eslint-disable
|
||||
no-unmodified-loop-condition,
|
||||
no-unused-vars,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS101: Remove unnecessary use of Array.from
|
||||
|
@ -21,7 +27,7 @@ module.exports = (ProjectIterator =
|
|||
|
||||
next(callback) {
|
||||
// what's up next
|
||||
//console.log ">>> top item", iterator.packs[0]
|
||||
// console.log ">>> top item", iterator.packs[0]
|
||||
const iterator = this;
|
||||
const { before } = this;
|
||||
const { queue } = iterator;
|
||||
|
@ -30,10 +36,10 @@ module.exports = (ProjectIterator =
|
|||
let lowWaterMark = (nextPack != null ? nextPack.meta.end_ts : undefined) || 0;
|
||||
let nextItem = queue.peek();
|
||||
|
||||
//console.log "queue empty?", queue.empty()
|
||||
//console.log "nextItem", nextItem
|
||||
//console.log "nextItem.meta.end_ts", nextItem?.meta.end_ts
|
||||
//console.log "lowWaterMark", lowWaterMark
|
||||
// console.log "queue empty?", queue.empty()
|
||||
// console.log "nextItem", nextItem
|
||||
// console.log "nextItem.meta.end_ts", nextItem?.meta.end_ts
|
||||
// console.log "lowWaterMark", lowWaterMark
|
||||
|
||||
while ((before != null) && ((nextPack != null ? nextPack.meta.start_ts : undefined) > before)) {
|
||||
// discard pack that is outside range
|
||||
|
@ -47,9 +53,9 @@ module.exports = (ProjectIterator =
|
|||
return this.getPackByIdFn(nextPack.project_id, nextPack.doc_id, nextPack._id, function(err, pack) {
|
||||
if (err != null) { return callback(err); }
|
||||
iterator.packs.shift(); // have now retrieved this pack, remove it
|
||||
//console.log "got pack", pack
|
||||
for (let op of Array.from(pack.pack)) {
|
||||
//console.log "adding op", op
|
||||
// console.log "got pack", pack
|
||||
for (const op of Array.from(pack.pack)) {
|
||||
// console.log "adding op", op
|
||||
if ((before == null) || (op.meta.end_ts < before)) {
|
||||
op.doc_id = nextPack.doc_id;
|
||||
op.project_id = nextPack.project_id;
|
||||
|
@ -61,15 +67,15 @@ module.exports = (ProjectIterator =
|
|||
});
|
||||
}
|
||||
|
||||
//console.log "nextItem", nextItem, "lowWaterMark", lowWaterMark
|
||||
// console.log "nextItem", nextItem, "lowWaterMark", lowWaterMark
|
||||
while ((nextItem != null) && ((nextItem != null ? nextItem.meta.end_ts : undefined) > lowWaterMark)) {
|
||||
opsToReturn.push(nextItem);
|
||||
queue.pop();
|
||||
nextItem = queue.peek();
|
||||
}
|
||||
|
||||
//console.log "queue empty?", queue.empty()
|
||||
//console.log "nextPack", nextPack?
|
||||
// console.log "queue empty?", queue.empty()
|
||||
// console.log "nextPack", nextPack?
|
||||
|
||||
if (queue.empty() && (nextPack == null)) { // got everything
|
||||
iterator._done = true;
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS101: Remove unnecessary use of Array.from
|
||||
|
@ -36,7 +42,7 @@ module.exports = (RedisManager = {
|
|||
if (callback == null) { callback = function(error) {}; }
|
||||
const multi = rclient.multi();
|
||||
// Delete all the updates which have been applied (exact match)
|
||||
for (let update of Array.from(docUpdates || [])) {
|
||||
for (const update of Array.from(docUpdates || [])) {
|
||||
multi.lrem(Keys.uncompressedHistoryOps({doc_id}), 1, update);
|
||||
}
|
||||
return multi.exec(function(error, results) {
|
||||
|
@ -72,7 +78,7 @@ module.exports = (RedisManager = {
|
|||
let keys;
|
||||
if (error != null) { return callback(error); }
|
||||
[cursor, keys] = Array.from(reply);
|
||||
for (let key of Array.from(keys)) {
|
||||
for (const key of Array.from(keys)) {
|
||||
keySet[key] = true;
|
||||
}
|
||||
if (cursor === '0') { // note redis returns string result not numeric
|
||||
|
@ -90,7 +96,7 @@ module.exports = (RedisManager = {
|
|||
_extractIds(keyList) {
|
||||
const ids = (() => {
|
||||
const result = [];
|
||||
for (let key of Array.from(keyList)) {
|
||||
for (const key of Array.from(keyList)) {
|
||||
const m = key.match(/:\{?([0-9a-f]{24})\}?/); // extract object id
|
||||
result.push(m[1]);
|
||||
}
|
||||
|
|
|
@ -1,3 +1,10 @@
|
|||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
no-unused-vars,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
|
|
|
@ -1,3 +1,12 @@
|
|||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
new-cap,
|
||||
no-throw-literal,
|
||||
no-unused-vars,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS101: Remove unnecessary use of Array.from
|
||||
|
@ -31,7 +40,7 @@ module.exports = (UpdateCompressor = {
|
|||
// }]
|
||||
convertToSingleOpUpdates(updates) {
|
||||
const splitUpdates = [];
|
||||
for (let update of Array.from(updates)) {
|
||||
for (const update of Array.from(updates)) {
|
||||
// Reject any non-insert or delete ops, i.e. comments
|
||||
const ops = update.op.filter(o => (o.i != null) || (o.d != null));
|
||||
if (ops.length === 0) {
|
||||
|
@ -45,7 +54,7 @@ module.exports = (UpdateCompressor = {
|
|||
v: update.v
|
||||
});
|
||||
} else {
|
||||
for (let op of Array.from(ops)) {
|
||||
for (const op of Array.from(ops)) {
|
||||
splitUpdates.push({
|
||||
op,
|
||||
meta: {
|
||||
|
@ -63,7 +72,7 @@ module.exports = (UpdateCompressor = {
|
|||
|
||||
concatUpdatesWithSameVersion(updates) {
|
||||
const concattedUpdates = [];
|
||||
for (let update of Array.from(updates)) {
|
||||
for (const update of Array.from(updates)) {
|
||||
const lastUpdate = concattedUpdates[concattedUpdates.length - 1];
|
||||
if ((lastUpdate != null) && (lastUpdate.v === update.v)) {
|
||||
if (update.op !== UpdateCompressor.NOOP) { lastUpdate.op.push(update.op); }
|
||||
|
@ -98,7 +107,7 @@ module.exports = (UpdateCompressor = {
|
|||
if (updates.length === 0) { return []; }
|
||||
|
||||
let compressedUpdates = [updates.shift()];
|
||||
for (let update of Array.from(updates)) {
|
||||
for (const update of Array.from(updates)) {
|
||||
const lastCompressedUpdate = compressedUpdates.pop();
|
||||
if (lastCompressedUpdate != null) {
|
||||
compressedUpdates = compressedUpdates.concat(UpdateCompressor._concatTwoUpdates(lastCompressedUpdate, update));
|
||||
|
@ -249,7 +258,7 @@ module.exports = (UpdateCompressor = {
|
|||
|
||||
const ops = [];
|
||||
let position = 0;
|
||||
for (let diff of Array.from(diffs)) {
|
||||
for (const diff of Array.from(diffs)) {
|
||||
const type = diff[0];
|
||||
const content = diff[1];
|
||||
if (type === this.ADDED) {
|
||||
|
|
|
@ -1,3 +1,10 @@
|
|||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
no-unused-vars,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
|
|
|
@ -1,3 +1,10 @@
|
|||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
no-unused-vars,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS101: Remove unnecessary use of Array.from
|
||||
|
@ -195,7 +202,7 @@ module.exports = (UpdatesManager = {
|
|||
if (error != null) { return callback(error); }
|
||||
return UpdatesManager._prepareProjectForUpdates(project_id, function(error, temporary) {
|
||||
const jobs = [];
|
||||
for (let doc_id of Array.from(doc_ids)) {
|
||||
for (const doc_id of Array.from(doc_ids)) {
|
||||
(doc_id =>
|
||||
jobs.push(cb => UpdatesManager._processUncompressedUpdatesForDocWithLock(project_id, doc_id, temporary, cb))
|
||||
)(doc_id);
|
||||
|
@ -269,7 +276,7 @@ module.exports = (UpdatesManager = {
|
|||
if (callback == null) { callback = function(error, updates) {}; }
|
||||
return UpdatesManager.processUncompressedUpdatesWithLock(project_id, doc_id, function(error) {
|
||||
if (error != null) { return callback(error); }
|
||||
//console.log "options", options
|
||||
// console.log "options", options
|
||||
return PackManager.getOpsByVersionRange(project_id, doc_id, options.from, options.to, function(error, updates) {
|
||||
if (error != null) { return callback(error); }
|
||||
return callback(null, updates);
|
||||
|
@ -302,14 +309,14 @@ module.exports = (UpdatesManager = {
|
|||
if (err != null) { return callback(err); }
|
||||
// repeatedly get updates and pass them through the summariser to get an final output with user info
|
||||
return async.whilst(() =>
|
||||
//console.log "checking iterator.done", iterator.done()
|
||||
// console.log "checking iterator.done", iterator.done()
|
||||
(summarizedUpdates.length < options.min_count) && !iterator.done()
|
||||
|
||||
, cb =>
|
||||
iterator.next(function(err, partialUpdates) {
|
||||
if (err != null) { return callback(err); }
|
||||
//logger.log {partialUpdates}, 'got partialUpdates'
|
||||
if (partialUpdates.length === 0) { return cb(); } //# FIXME should try to avoid this happening
|
||||
// logger.log {partialUpdates}, 'got partialUpdates'
|
||||
if (partialUpdates.length === 0) { return cb(); } // # FIXME should try to avoid this happening
|
||||
nextBeforeTimestamp = partialUpdates[partialUpdates.length - 1].meta.end_ts;
|
||||
// add the updates to the summary list
|
||||
summarizedUpdates = UpdatesManager._summarizeUpdates(partialUpdates, summarizedUpdates);
|
||||
|
@ -318,7 +325,7 @@ module.exports = (UpdatesManager = {
|
|||
|
||||
, () =>
|
||||
// finally done all updates
|
||||
//console.log 'summarized Updates', summarizedUpdates
|
||||
// console.log 'summarized Updates', summarizedUpdates
|
||||
UpdatesManager.fillSummarizedUserInfo(summarizedUpdates, function(err, results) {
|
||||
if (err != null) { return callback(err); }
|
||||
return callback(null, results, !iterator.done() ? nextBeforeTimestamp : undefined);
|
||||
|
@ -332,7 +339,7 @@ module.exports = (UpdatesManager = {
|
|||
if (callback == null) { callback = function(error, fetchedUserInfo) {}; }
|
||||
const jobs = [];
|
||||
const fetchedUserInfo = {};
|
||||
for (let user_id in users) {
|
||||
for (const user_id in users) {
|
||||
(user_id =>
|
||||
jobs.push(callback =>
|
||||
WebApiManager.getUserInfo(user_id, function(error, userInfo) {
|
||||
|
@ -419,7 +426,7 @@ module.exports = (UpdatesManager = {
|
|||
if (existingSummarizedUpdates == null) { existingSummarizedUpdates = []; }
|
||||
const summarizedUpdates = existingSummarizedUpdates.slice();
|
||||
let previousUpdateWasBigDelete = false;
|
||||
for (let update of Array.from(updates)) {
|
||||
for (const update of Array.from(updates)) {
|
||||
var doc_id;
|
||||
const earliestUpdate = summarizedUpdates[summarizedUpdates.length - 1];
|
||||
let shouldConcat = false;
|
||||
|
@ -439,7 +446,7 @@ module.exports = (UpdatesManager = {
|
|||
}
|
||||
|
||||
let isBigDelete = false;
|
||||
for (let op of Array.from(update.op || [])) {
|
||||
for (const op of Array.from(update.op || [])) {
|
||||
if ((op.d != null) && (op.d.length > this.SPLIT_ON_DELETE_SIZE)) {
|
||||
isBigDelete = true;
|
||||
}
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Sanity-check the conversion and remove this comment.
|
||||
const Settings = require("settings-sharelatex");
|
||||
const mongojs = require("mongojs");
|
||||
const bson = require("bson");
|
||||
|
|
Loading…
Reference in a new issue