Showing
1 changed file
with
3 additions
and
3 deletions
... | @@ -16,7 +16,6 @@ app.use(bodyParser.json()); | ... | @@ -16,7 +16,6 @@ app.use(bodyParser.json()); |
16 | app.post('/hook', function (req, res) { | 16 | app.post('/hook', function (req, res) { |
17 | 17 | ||
18 | var eventObj = req.body.events[0]; | 18 | var eventObj = req.body.events[0]; |
19 | - var source = eventObj.source; | ||
20 | var message = eventObj.message; | 19 | var message = eventObj.message; |
21 | 20 | ||
22 | function output_message(results, list) { | 21 | function output_message(results, list) { |
... | @@ -64,6 +63,7 @@ app.post('/hook', function (req, res) { | ... | @@ -64,6 +63,7 @@ app.post('/hook', function (req, res) { |
64 | db.connect(); | 63 | db.connect(); |
65 | 64 | ||
66 | var max = 0; | 65 | var max = 0; |
66 | + var arr2; | ||
67 | 67 | ||
68 | db.query('SELECT * FROM recipe', function (error, results, fields) { | 68 | db.query('SELECT * FROM recipe', function (error, results, fields) { |
69 | if (error) { | 69 | if (error) { |
... | @@ -77,7 +77,7 @@ app.post('/hook', function (req, res) { | ... | @@ -77,7 +77,7 @@ app.post('/hook', function (req, res) { |
77 | var count = ingredients_list.filter(x => input_ingredients_list.includes(x)).length; | 77 | var count = ingredients_list.filter(x => input_ingredients_list.includes(x)).length; |
78 | if (count > max) { | 78 | if (count > max) { |
79 | max = count; | 79 | max = count; |
80 | - var arr2 = new Array(); | 80 | + arr2 = new Array(); |
81 | } | 81 | } |
82 | if (count === input_ingredients_list.length) { | 82 | if (count === input_ingredients_list.length) { |
83 | arr1.push(i); | 83 | arr1.push(i); |
... | @@ -91,7 +91,7 @@ app.post('/hook', function (req, res) { | ... | @@ -91,7 +91,7 @@ app.post('/hook', function (req, res) { |
91 | output_message(results, arr1); | 91 | output_message(results, arr1); |
92 | } | 92 | } |
93 | 93 | ||
94 | - else if (arr2.length != 0) { | 94 | + else if (arr2 != undefined) { |
95 | output_message(results, arr2); | 95 | output_message(results, arr2); |
96 | } | 96 | } |
97 | else { | 97 | else { | ... | ... |
-
Please register or login to post a comment