From 29b2e6bd9e94cf7f61fe9112162439d010e3d44f Mon Sep 17 00:00:00 2001 From: schneefux Date: Sun, 23 Apr 2017 10:07:01 +0200 Subject: filter by region using a join --- worker.js | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/worker.js b/worker.js index 2b456b9..baf9a33 100644 --- a/worker.js +++ b/worker.js @@ -113,9 +113,6 @@ function* chunks(arr) { // merge custom filters Object.assign(where_aggr, tuple[1].get("filter")); - // region is filter by name not by id - } else if (tuple[0].tableName == "region") { - where_aggr["$participant.shard_id$"] = tuple[1].get("name"); // series and skill_tier are ranged filters } else if (tuple[0].tableName == "series") { // use start < date < end comparison @@ -131,6 +128,7 @@ function* chunks(arr) { // build is a special ranged filter } else if (tuple[0].tableName == "build") { // TODO! + // filtering is done via JOINs } else where_aggr["$participant." + tuple[0].tableName + ".id$"] = tuple[1].id } @@ -261,13 +259,14 @@ function* chunks(arr) { model: model.Participant, as: "participant", attributes: [], - include: [ { - model: model.Roster, - attributes: [], - include: [ { - model: model.Match, - attributes: [] - } ] + include: [ + { + model: model.Roster, + attributes: [], + include: [ { + model: model.Match, + attributes: [] + } ] }, { model: model.Hero, as: "hero", @@ -284,7 +283,11 @@ function* chunks(arr) { model: model.Role, as: "role", attributes: [] - } ] + }, { + model: model.Region, + as: "region", + attributes: [] + } ] } ]; const played = await model.ParticipantStats.count({ -- cgit v1.3.1