Skip to content

Instantly share code, notes, and snippets.

@LeZuse
Created May 21, 2018 16:17
Show Gist options
  • Select an option

  • Save LeZuse/a0b4d7de30fcec8e9d6d07103b46fcb7 to your computer and use it in GitHub Desktop.

Select an option

Save LeZuse/a0b4d7de30fcec8e9d6d07103b46fcb7 to your computer and use it in GitHub Desktop.
Parse out unique class names from resque failed list
#!/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