From 61c4c703f8736b970ddb3377abafd51f4e2aae6a Mon Sep 17 00:00:00 2001 From: Mark Lise Date: Thu, 21 Sep 2017 19:17:57 -0700 Subject: [PATCH] MEM-510: Search Improvements. --- modules/core/server/controllers/core.dbmodel.controller.js | 5 ++++- modules/search/server/routes/search.routes.js | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/modules/core/server/controllers/core.dbmodel.controller.js b/modules/core/server/controllers/core.dbmodel.controller.js index 6480d09ac..d9bdd62f8 100644 --- a/modules/core/server/controllers/core.dbmodel.controller.js +++ b/modules/core/server/controllers/core.dbmodel.controller.js @@ -372,7 +372,10 @@ _.extend (DBModel.prototype, { q = _.extend (q, {"documentDate" : { $lte : new Date(dateRangeEnd) }}); } if (project) { - q = _.extend (q, {"project" : project}); + var projects = project.split(','); + if (projects.length > 0) { + q = _.extend(q, { "project": {$in : projects}}); + } } console.log("q:", q); diff --git a/modules/search/server/routes/search.routes.js b/modules/search/server/routes/search.routes.js index 041e5b70d..9320a8049 100644 --- a/modules/search/server/routes/search.routes.js +++ b/modules/search/server/routes/search.routes.js @@ -24,7 +24,9 @@ module.exports = function (app) { var projectQuery = {}; // TODO: Make sure this is a valid objectID, wrap with try/catches. if (req.query.project) { - projectQuery = { _id: req.query.project }; + projects = req.query.project.split(','); + projectQuery = _.extend (projectQuery, { "_id": {$in : projects}}); + console.log("project query:", projectQuery); } // TBD // if (req.query.oweneroperator) {