From 899061067039105f3cd639e553bf85ae6eb5684f Mon Sep 17 00:00:00 2001 From: schneefux Date: Tue, 16 May 2017 12:45:43 +0200 Subject: add Telemetry dl endpoint --- server.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'server.js') diff --git a/server.js b/server.js index d93162e..48647f7 100644 --- a/server.js +++ b/server.js @@ -467,9 +467,20 @@ app.post("/api/samples", async (req, res) => { }); // download Telemetry app.post("/api/match/:match/telemetry", async (req, res) => { - logger.info("requesting download for Telemetry", { api_id: req.params.api_id }); - await ch.sendToQueue(SAMPLE_QUEUE, new Buffer(req.params.api_id), - { persistent: true, type: "telemetry" }); + logger.info("requesting download for Telemetry", { api_id: req.params.match }); + const asset = await model.Asset.findOne({ where: { + match_api_id: req.params.match + } }); + if (asset == undefined) { + logger.error("could not find any assets for match", + { api_id: req.params.match }); + res.sendStatus(404); + return; + } + await ch.sendToQueue(SAMPLE_QUEUE, new Buffer(JSON.stringify(asset.url)), { + persistent: true, type: "telemetry", + headers: { match_api_id: req.params.match } + }); res.sendStatus(204); }); // crunch all global stats -- cgit v1.3.1