From 991bdc608973f0056afc26b24d2d356459ca7f77 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Fri, 16 Jun 2017 16:18:02 -0300 Subject: [PATCH] Updated BE --- graph/loaders/assets.js | 5 ++--- routes/api/assets/index.js | 4 ++-- test/server/routes/api/assets/index.js | 1 + 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/graph/loaders/assets.js b/graph/loaders/assets.js index 7e924e14a..020eafbcb 100644 --- a/graph/loaders/assets.js +++ b/graph/loaders/assets.js @@ -22,8 +22,7 @@ const genAssetsByID = (context, ids) => AssetModel.find({ /** * [getAssetsByQuery description] * @param {Object} context the context of the request - * @param {String} value text string to search agains the documents - * @param {Number} limit limit the number of results + * @param {Object} query the query * @return {Promise} resolves the assets */ const getAssetsByQuery = (context, query) => { @@ -76,7 +75,7 @@ module.exports = (context) => ({ // this operation create a new asset if one isn't found. getByURL: (url) => findOrCreateAssetByURL(context, url), - search: (value, limit) => getAssetsByQuery(context, value, limit), + search: (query) => getAssetsByQuery(context, query), getByID: new DataLoader((ids) => genAssetsByID(context, ids)), getForMetrics: () => getAssetsForMetrics(context), getAll: new util.SingletonResolver(() => AssetModel.find({})) diff --git a/routes/api/assets/index.js b/routes/api/assets/index.js index 3bb3ef778..f02b49f7e 100644 --- a/routes/api/assets/index.js +++ b/routes/api/assets/index.js @@ -48,13 +48,13 @@ router.get('/', (req, res, next) => { Promise.all([ // Find the actuall assets. - FilterOpenAssets(AssetsService.search(search), filter) + FilterOpenAssets(AssetsService.search({value: search}), filter) .sort({[field]: (sort === 'asc') ? 1 : -1}) .skip(parseInt(skip)) .limit(parseInt(limit)), // Get the count of actual assets. - FilterOpenAssets(AssetsService.search(search), filter) + FilterOpenAssets(AssetsService.search({value: search}), filter) .count() ]) .then(([result, count]) => { diff --git a/test/server/routes/api/assets/index.js b/test/server/routes/api/assets/index.js index 80708688b..62c4cdb47 100644 --- a/test/server/routes/api/assets/index.js +++ b/test/server/routes/api/assets/index.js @@ -43,6 +43,7 @@ describe('/api/v1/assets', () => { .set(passport.inject({roles: ['ADMIN']})) .then((res) => { const body = res.body; + console.log(body) expect(body).to.have.property('count', 2); expect(body).to.have.property('result');