Skip to content

Instantly share code, notes, and snippets.

@kevireilly
Last active April 21, 2016 01:42
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 kevireilly/6ba676b23509efbfc172611ed5765f40 to your computer and use it in GitHub Desktop.
Save kevireilly/6ba676b23509efbfc172611ed5765f40 to your computer and use it in GitHub Desktop.
function getOutput(requestID, _poolName) {
var url = SEARCH_URL + '/' + requestID + '/output';
request.get(url, function(err, response, body) {
if (err) {
console.error("Error requesting URL", url, err);
} else {
if (body) {
console.log("Writing json response to " + _poolName + ".json");
writeJSON(_poolname, body);
} else {
console.warn("No log found!");
process.exit()
}
}
})
}
function writeJSON(name, json){
var filename = name + ".json";
fs.writeFile(filename, json, function(err) {
if (err) {
console.error("Error writing to file", filename, err);
} else {
var obj = parseJSON(json);
if (obj.totalCount > 0) {
console.log("Event Type Pattern : " + obj.records[0].values.Type + " count is : " + obj.totalCount);
}
if (_dataObjA == null) {
_dataObjA = obj;
} else {
_dataObjB = obj;
}
obj = null;
compare();
}
});
}
function parseJSON(json){
try {
var obj = JSON.parse(json);
return obj;
} catch (err){
console.error("Error parsing JSON", err);
return {};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment