From 1af24ac18a2b6f1b1f1d8aa5b62cebef383caf5b Mon Sep 17 00:00:00 2001 From: schneefux Date: Sat, 8 Apr 2017 00:00:33 +0200 Subject: implement simple sample downloads --- index.html | 11 +++++++++++ server.js | 15 ++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index f12c585..dd1bf7d 100644 --- a/index.html +++ b/index.html @@ -17,6 +17,11 @@

+

+

+ +
+

@@ -99,6 +104,12 @@ subscribe(resp.name); }); }); + $("#get-samples-form").submit((e) => { + e.preventDefault(); + $.post("/api/samples").done((resp) => { + notif("downloading samples", "green"); + }); + }); $("#crunch-form").submit((e) => { e.preventDefault(); diff --git a/server.js b/server.js index c921d00..e16090a 100644 --- a/server.js +++ b/server.js @@ -60,7 +60,7 @@ function requestUpdate(name, region, last_match_created_date, id) { }; console.log("requesting update for", name, region); return ch.sendToQueue("grab", new Buffer(JSON.stringify(payload)), - { persistent: true }); + { persistent: true, type: "matches" }); } // search for player name on all shards @@ -159,6 +159,19 @@ app.post("/api/player", async (req, res) => { await updatePlayer(player); res.json(player); }); +// download sample sets +// (TODO download only samples since last update) +app.post("/api/samples", async (req, res) => { + await ch.sendToQueue("grab", new Buffer( + JSON.stringify({ + region: "eu", + params: { + sort: "-createdAt" + } + })), + { persistent: true, type: "samples" }); + res.sendStatus(204); +}); // crunch data app.post("/api/stats/:dimension_on/update", async (req, res) => { -- cgit v1.3.1