diff options
| author | schneefux <schneefux+commit@schneefux.xyz> | 2017-05-16 12:45:43 +0200 |
|---|---|---|
| committer | schneefux <schneefux+commit@schneefux.xyz> | 2017-05-16 12:45:43 +0200 |
| commit | 899061067039105f3cd639e553bf85ae6eb5684f (patch) | |
| tree | 13428bbb9ab93a039ac77eab2a99301f956f2a64 | |
| parent | b33b4227b89c08f8b663351bd9513f4afa15a943 (diff) | |
| download | bridge-899061067039105f3cd639e553bf85ae6eb5684f.tar.gz bridge-899061067039105f3cd639e553bf85ae6eb5684f.zip | |
add Telemetry dl endpoint
| -rw-r--r-- | server.js | 17 |
1 files changed, 14 insertions, 3 deletions
@@ -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 |
