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
"dag": { | |
... | |
"nodes":[{ | |
"#": "First Node", | |
"input": { | |
"bucket": "gmailEmails" | |
}, | |
"implementation": { | |
"javascript": "server/node1.js" | |
}, |
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'); | |
// ... | |
let counts = others.map(value => { | |
let text = value.textBody || value.strippedHtmlBody || ''; | |
let count = textUtils.splitWords(textUtils.trimEmailThreads(text)).length; | |
return count; | |
}); | |
console.log(counts); |
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)); |
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": { | |
"inputs": { | |
"rpc": { | |
"simple_rpc": { | |
"methods": ["GET"], | |
"path": "/simple", | |
"CORS": {} | |
} | |
} |
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": { | |
"inputs":{ | |
"rpc":{ | |
"simple_rpc":{ | |
"methods": ["GET"], | |
"path": "/edig/txt/*", | |
"CORS":{} | |
} | |
} | |
}, |
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
const dns = require('dns'); | |
const pify = require('pify'); | |
//... | |
module.exports = function (got) { | |
const inData = got.in.data; | |
console.log('edig: simple.js: data received:', inData); | |
return inData.map(d => { |
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
const newResponse = (status_code, header, body) => { | |
return { status_code, header, | |
body: Buffer.from(JSON.stringify(body) || '').toString('base64') | |
} | |
} | |
module.exports = function (got) { | |
const inData = got.in.data; | |
console.log('edig: simple.js: data received:', inData); |
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
func Compute(req sandboxrpc.ComputeRequest) ([]sandboxrpc.ComputeResponse, error) { | |
idx, err := utils.OpenIndex(false) | |
if err != nil { | |
return nil, errors.New("Something went wrong while creating the index: " + err.Error()) | |
} | |
defer idx.Close() | |
datums, err := fetchMajesticCSV() | |
if err != nil { | |
return nil, err |
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
func Compute(req sandboxrpc.ComputeRequest) ([]sandboxrpc.ComputeResponse, error) { | |
inData := req.In.Data | |
if len(inData) != 1 { | |
return nil, fmt.Errorf("empty input") | |
} | |
var resp []sandboxrpc.ComputeResponse | |
v := inData[0] | |
idx, err := utils.OpenIndex(true) | |
if err != nil { |