From 720c680c0902fcc3a3c56457120416a7893480d9 Mon Sep 17 00:00:00 2001 From: schneefux Date: Fri, 12 May 2017 19:13:52 +0200 Subject: send matches_none on no matches for player --- worker.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/worker.js b/worker.js index fc66ae4..d6befcb 100644 --- a/worker.js +++ b/worker.js @@ -69,7 +69,7 @@ if (LOGGLY_TOKEN) // loop over API data objects async function getAPI(payload, where, notify="global") { - await Promise.each(await api.requests(where, + const data = await Promise.each(await api.requests(where, payload.region, payload.params, logger), async (data, idx, len) => { if (where == "matches") // send match structure @@ -84,8 +84,12 @@ if (LOGGLY_TOKEN) await ch.sendToQueue(SAMPLE_QUEUE, new Buffer(JSON.stringify(data.attributes.URL)), { persistent: true, type: "sample" }); + return data; } ); + if (data.length == 0 && notify) + await ch.publish("amq.topic", notify, + new Buffer("matches_none")); } })(); -- cgit v1.3.1