Skip to content

Instantly share code, notes, and snippets.

@demosifter
Last active October 25, 2016 00:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save demosifter/3668418a36d24e1efc7372e286ef8124 to your computer and use it in GitHub Desktop.
Save demosifter/3668418a36d24e1efc7372e286ef8124 to your computer and use it in GitHub Desktop.
making our node implementation to output data for export
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