Created
May 21, 2018 16:17
-
-
Save LeZuse/a0b4d7de30fcec8e9d6d07103b46fcb7 to your computer and use it in GitHub Desktop.
Parse out unique class names from resque failed list
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
| #!/bin/env node | |
| const fs = require('fs'); | |
| // this takes a few seconds | |
| // -u supported from v4 | |
| // redis-cli -u `heroku redis:credentials -a pb-com` lrange resque:failed 0 -1 > failed.txt | |
| const log = fs.readFileSync('failed.txt', {encoding:'utf8'}); | |
| const ln = log.split('\n'); | |
| console.log(ln.length); | |
| const RE = /class":"([^"]+)"/; | |
| const stats = ln.reduce((hash, line) => { | |
| var m = line.match(RE); | |
| if (m && m[1]) | |
| hash[m[1]] = hash[m[1]] ? hash[m[1]] + 1 : 1; | |
| return hash; | |
| }, {}); | |
| console.log(stats); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment