mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Manual tidying
This commit is contained in:
parent
de50e59557
commit
f4db3d8f45
3 changed files with 11 additions and 47 deletions
|
@ -1,16 +1,3 @@
|
||||||
/* eslint-disable
|
|
||||||
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
|
|
||||||
* DS102: Remove unnecessary code created because of implicit returns
|
|
||||||
* DS207: Consider shorter variations of null checks
|
|
||||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
|
||||||
*/
|
|
||||||
const Settings = require('settings-sharelatex')
|
const Settings = require('settings-sharelatex')
|
||||||
const rclient = require('@overleaf/redis-wrapper').createClient(
|
const rclient = require('@overleaf/redis-wrapper').createClient(
|
||||||
Settings.redis.documentupdater
|
Settings.redis.documentupdater
|
||||||
|
@ -23,17 +10,17 @@ const getKeysFromNode = function (node, pattern, callback) {
|
||||||
let cursor = 0 // redis iterator
|
let cursor = 0 // redis iterator
|
||||||
const keySet = {} // use hash to avoid duplicate results
|
const keySet = {} // use hash to avoid duplicate results
|
||||||
// scan over all keys looking for pattern
|
// scan over all keys looking for pattern
|
||||||
var doIteration = (cb) =>
|
const doIteration = () =>
|
||||||
node.scan(cursor, 'MATCH', pattern, 'COUNT', 1000, function (error, reply) {
|
node.scan(cursor, 'MATCH', pattern, 'COUNT', 1000, function(error, reply) {
|
||||||
if (error != null) {
|
if (error) {
|
||||||
return callback(error)
|
return callback(error)
|
||||||
}
|
}
|
||||||
;[cursor, keys] = Array.from(reply)
|
;[cursor, keys] = reply
|
||||||
console.log('SCAN', keys.length)
|
console.log('SCAN', keys.length)
|
||||||
for (const key of Array.from(keys)) {
|
for (const key of keys) {
|
||||||
keySet[key] = true
|
keySet[key] = true
|
||||||
}
|
}
|
||||||
if (cursor === '0') {
|
if (cursor==='0') {
|
||||||
// note redis returns string result not numeric
|
// note redis returns string result not numeric
|
||||||
return callback(null, Object.keys(keySet))
|
return callback(null, Object.keys(keySet))
|
||||||
} else {
|
} else {
|
||||||
|
@ -52,8 +39,8 @@ const getKeys = function (pattern, callback) {
|
||||||
return async.concatSeries(nodes, doKeyLookupForNode, callback)
|
return async.concatSeries(nodes, doKeyLookupForNode, callback)
|
||||||
}
|
}
|
||||||
|
|
||||||
const TTL = 60 * 60 // 1 hour
|
|
||||||
const expireDocOps = (callback) =>
|
const expireDocOps = (callback) =>
|
||||||
|
// eslint-disable-next-line handle-callback-err
|
||||||
getKeys(keys.docOps({ doc_id: '*' }), (error, keys) =>
|
getKeys(keys.docOps({ doc_id: '*' }), (error, keys) =>
|
||||||
async.mapSeries(
|
async.mapSeries(
|
||||||
keys,
|
keys,
|
||||||
|
@ -69,7 +56,7 @@ setTimeout(
|
||||||
() =>
|
() =>
|
||||||
// Give redis a chance to connect
|
// Give redis a chance to connect
|
||||||
expireDocOps(function (error) {
|
expireDocOps(function (error) {
|
||||||
if (error != null) {
|
if (error) {
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
return process.exit()
|
return process.exit()
|
||||||
|
|
|
@ -1,15 +1,3 @@
|
||||||
/* eslint-disable
|
|
||||||
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
|
|
||||||
* DS102: Remove unnecessary code created because of implicit returns
|
|
||||||
* DS207: Consider shorter variations of null checks
|
|
||||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
|
||||||
*/
|
|
||||||
let listenInBackground, sendPings
|
let listenInBackground, sendPings
|
||||||
const redis = require('@overleaf/redis-wrapper')
|
const redis = require('@overleaf/redis-wrapper')
|
||||||
const rclient1 = redis.createClient({
|
const rclient1 = redis.createClient({
|
||||||
|
@ -52,7 +40,7 @@ const listenForPing = (cb) =>
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
return cb(error)
|
return cb(error)
|
||||||
}
|
}
|
||||||
let [key, value] = Array.from(result)
|
let [, value] = Array.from(result)
|
||||||
value = parseInt(value, 10)
|
value = parseInt(value, 10)
|
||||||
if (value % 10 === 0) {
|
if (value % 10 === 0) {
|
||||||
console.log('.')
|
console.log('.')
|
||||||
|
@ -70,7 +58,7 @@ const PING_DELAY = 100
|
||||||
;(sendPings = () => sendPing(() => setTimeout(sendPings, PING_DELAY)))()
|
;(sendPings = () => sendPing(() => setTimeout(sendPings, PING_DELAY)))()
|
||||||
|
|
||||||
;(listenInBackground = () =>
|
;(listenInBackground = () =>
|
||||||
listenForPing((error, value) => {
|
listenForPing((error) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
console.error('[RECEIVING ERROR]', error.message)
|
console.error('[RECEIVING ERROR]', error.message)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,3 @@
|
||||||
/* eslint-disable
|
|
||||||
no-return-assign,
|
|
||||||
*/
|
|
||||||
// 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
|
|
||||||
* DS207: Consider shorter variations of null checks
|
|
||||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
|
||||||
*/
|
|
||||||
let sendPings
|
let sendPings
|
||||||
const redis = require('@overleaf/redis-wrapper')
|
const redis = require('@overleaf/redis-wrapper')
|
||||||
const rclient1 = redis.createClient({
|
const rclient1 = redis.createClient({
|
||||||
|
@ -35,7 +24,7 @@ const sendPing = function (cb) {
|
||||||
cb = function () {}
|
cb = function () {}
|
||||||
}
|
}
|
||||||
return rclient1.publish('test-pubsub', counter, (error) => {
|
return rclient1.publish('test-pubsub', counter, (error) => {
|
||||||
if (error != null) {
|
if (error) {
|
||||||
console.error('[SENDING ERROR]', error.message)
|
console.error('[SENDING ERROR]', error.message)
|
||||||
}
|
}
|
||||||
if (error == null) {
|
if (error == null) {
|
||||||
|
|
Loading…
Reference in a new issue