Last active
April 21, 2016 01:42
-
-
Save kevireilly/6ba676b23509efbfc172611ed5765f40 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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