Commit 781db388 authored by marioromera's avatar marioromera
Browse files

ensure redis to be connected to request revisions

parent c32911b8
......@@ -18,7 +18,7 @@ let subscriber = redis.createClient({
const REVS_RATIO = 0.25;
const PAD_ID = 'poc';
let redis_connected = false;
const socketsIps = {};
module.exports = io => {
if (subscriber) {
......@@ -27,6 +27,7 @@ module.exports = io => {
});
subscriber.on('connect', () => {
logger.success('Redis connected');
redis_connected = true;
subscriber.subscribe(`pad:${PAD_ID}`);
subscriber.on('message', (channel, message) => {
logger.warn('Pad updated', message);
......@@ -113,6 +114,7 @@ async function calculatePadTfidf() {
}
async function getRevisions() {
if (!redis_connected) return;
const response = await fetch(
`${etherpadUrl}/api/1/getRevisionsCount?apikey=${etherpadApiKey}&padID=${PAD_ID}`
);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment