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
//... | |
constructor() { | |
// You have to call the super() method to initialize the base class. | |
super(); | |
this.controller.subscribe('counts', this.onCounts.bind(this)); | |
} | |
// for more info: https://docs.redsift.com/docs/client-code-siftview | |
presentView(value) { | |
console.log('counter: presentView: ', value); |
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
constructor() { | |
// You have to call the super() method to initialize the base class. | |
super(); | |
this._suHandler = this.onStorageUpdate.bind(this); | |
} | |
loadView(state) { | |
console.log('counter: loadView', state); | |
this.storage.subscribe(['count'], this._suHandler); |
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
module.exports = function (got) { | |
const json = got.in.data.map(d => JSON.parse(d.value)); | |
const query = got.query; | |
const threadId = query[0]; | |
let newestCount = json | |
.sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime()) | |
.shift().count; | |
return [{ |
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
return { | |
key: `${value.threadId}/${value.id}`, // instead of 'value.id | |
value: { | |
count: count, | |
date: value.date | |
} | |
} |
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
"stores":{ | |
"messageCounts" : { | |
"key$schema":"string/string" | |
} | |
} |
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
"outputs":{ | |
"exports":{ | |
"count" : { | |
"key$schema":"string" | |
}, | |
"threads": { | |
"import": "_email.tid" | |
} | |
} | |
} |
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
module.exports = function (got) { | |
const total = got.in.data.reduce((p, d) => p + parseInt(d.value), 0); | |
return { | |
key: 'word_count', | |
value: total | |
} | |
} |
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
"nodes":[{ | |
"#": "First Node", | |
"input": { | |
"bucket": "gmailEmails" | |
}, | |
"implementation": { | |
"javascript": "server/node1.js" | |
}, | |
"outputs": { | |
"messageCounts": {} |
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
return { | |
key: value.id, // instead of 'word_count' | |
value: count | |
} |
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
"dag": { | |
... | |
"nodes":[{ | |
"#": "First Node", | |
"input": { | |
"bucket": "gmailEmails" | |
}, | |
"implementation": { | |
"javascript": "server/node1.js" | |
}, |