Last active
October 25, 2016 00:17
-
-
Save demosifter/3668418a36d24e1efc7372e286ef8124 to your computer and use it in GitHub Desktop.
making our node implementation to output data for export
This file contains 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
let textUtils = require('@redsift/text-utilities'); | |
module.exports = function (got) { | |
// got.in contains the key/value pairs that match the given query | |
const inData = got.in; | |
console.log('counter: node1.js: running...', inData.data); | |
const json = inData.data.map(d => JSON.parse(d.value)); | |
const others = json.filter(j => j.user !== j['from'].email); | |
let counts = others.map(value => { | |
let text = value.textBody || value.strippedHtmlBody || ''; | |
let count = textUtils.splitWords(textUtils.trimEmailThreads(text)).length; | |
return { | |
key: 'word_count', | |
value: count | |
} | |
}); | |
console.log('counter: node1.js: will output:', counts); | |
return counts; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment