From 872612a8d36e3940903aab40a370889f7fc399e4 Mon Sep 17 00:00:00 2001 From: Henry Oswald Date: Mon, 29 Feb 2016 12:50:37 +0000 Subject: [PATCH] added null check to health check controller --- services/spelling/app/coffee/HealthCheckController.coffee | 4 ++-- services/spelling/app/coffee/SpellingAPIController.coffee | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/services/spelling/app/coffee/HealthCheckController.coffee b/services/spelling/app/coffee/HealthCheckController.coffee index 80708cb6e3..c4f847f46d 100644 --- a/services/spelling/app/coffee/HealthCheckController.coffee +++ b/services/spelling/app/coffee/HealthCheckController.coffee @@ -12,8 +12,8 @@ module.exports = language: "en" timeout: 1000 * 20 request.post opts, (err, response, body)-> - console.log body?.misspellings[0]?.suggestions.length - numberOfSuggestions = body?.misspellings[0]?.suggestions?.length + console.log body?.misspellings?[0]?.suggestions.length + numberOfSuggestions = body?.misspellings?[0]?.suggestions?.length if numberOfSuggestions > 10 logger.log "health check passed" res.sendStatus 200 diff --git a/services/spelling/app/coffee/SpellingAPIController.coffee b/services/spelling/app/coffee/SpellingAPIController.coffee index 67a095d12d..9401d0b36d 100644 --- a/services/spelling/app/coffee/SpellingAPIController.coffee +++ b/services/spelling/app/coffee/SpellingAPIController.coffee @@ -10,7 +10,8 @@ module.exports = SpellingAPIController = if error? logger.err err:error, user_id:req?.params?.user_id, word_count: req?.body?.words?.length, "error processing spelling request" return res.sendStatus(500) - res.send(result) + # res.send(result) + res.writeHead 200 learn: (req, res, next) -> metrics.inc "spelling-learn", 0.1