Last active
May 20, 2019 01:03
-
-
Save mariotacke/f14d1f796d07beb8d26500ac0f38e59a to your computer and use it in GitHub Desktop.
blog-real-time-word-cloud
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.get('/api/channel/:channel/words', async function (req, res) { | |
const channel = `#${req.params.channel}`; | |
const args = [channel, '0', '50', 'WITHSCORES']; | |
const scores = []; | |
const range = await redisClient.zrevrangeAsync(args); | |
for (let i = 0; i < range.length; i += 2) { | |
scores.push({ | |
key: range[i], | |
value: parseInt(range[i + 1]), | |
}); | |
} | |
res.json({ channel, scores }); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment