diff --git a/server.js b/server.js index c72a3b9..3c0aed0 100644 --- a/server.js +++ b/server.js @@ -367,7 +367,7 @@ server.get('/api/backends/:backend/*', function(req, res, next) { // list collections server.get('/api/collections', function(req, res, next) { - aggregate(dbqueries.GET_DISTINCT_COLLECTIONS_WITH_COUNT_PIPELINE, 'collections') + aggregate(dbqueries.GET_DISTINCT_COLLECTIONS_PIPELINE, 'collections') .then(prepare) .then(data => { res.send(data); next(); }) .catch(err => next(err)); diff --git a/src/components/DiscoverSection.vue b/src/components/DiscoverSection.vue index d318295..c41c311 100644 --- a/src/components/DiscoverSection.vue +++ b/src/components/DiscoverSection.vue @@ -28,7 +28,6 @@ :multiple="true" :hideSelected="true" :closeOnSelect="false" :preserveSearch="true" openDirection="below"> diff --git a/src/dbqueries.js b/src/dbqueries.js index 47968a4..3673a91 100644 --- a/src/dbqueries.js +++ b/src/dbqueries.js @@ -65,7 +65,7 @@ module.exports = { } } ], GET_ALL_COLLECTIONS_PIPELINE: [ - { $match: { path: '/collections' } }, + { $match: { path: '/collections', 'content.collections': {$exists: true} } }, { $addFields: { 'content.collections.backend': '$backend', 'content.collections.backendTitle': '$backendTitle', 'content.collections.retrieved': '$retrieved', 'content.collections.unsuccessfulCrawls': '$unsuccessfulCrawls' } }, { $project: { 'collection': '$content.collections' } }, { $unwind: '$collection' }, @@ -73,7 +73,7 @@ module.exports = { ], GET_ALL_PROCESSES_PIPELINE: [ // basically like for collections - { $match: { path: '/processes' } }, + { $match: { path: '/processes', 'content.processes': {$exists: true} } }, { $addFields: { 'content.processes.backend': '$backend', 'content.processes.backendTitle': '$backendTitle', 'content.processes.retrieved': '$retrieved', 'content.processes.unsuccessfulCrawls': '$unsuccessfulCrawls' } }, { $project: { 'process': '$content.processes' } }, { $unwind: '$process' }, @@ -81,15 +81,14 @@ module.exports = { // convert `parameters` object to array because otherwise we can't search for parameter descriptions (MongoDB doesn't support wildcards for object keys) { $addFields: { 'parametersAsArray' : { $objectToArray: '$parameters' } } } ], - GET_DISTINCT_COLLECTIONS_WITH_COUNT_PIPELINE: [ + GET_DISTINCT_COLLECTIONS_PIPELINE: [ { $project: {id: {$ifNull: ["$id", "$name"]}, title: 1} }, // allow both id (v0.4) and name (v0.3) { $group: { // group by collection id, at the same time calculate the sum, and maintain title _id: {$toLower: "$id"}, id: {$first: "$id"}, title: {$first: "$title"}, // if a collection *does* appear twice, the title is usually the same, so just using the first occurrence is enough - count: {$sum: 1} } }, - { $sort: {count: -1, id: 1} } // sort by count DESC, id ASC + { $sort: {id: 1} } // sort by id ASC ], GET_DISTINCT_PROCESSES_WITH_COUNT_PIPELINE: [ { $project: {id: {$ifNull: ["$id", "$name"]}, summary: 1} }, // allow both id (v0.4) and name (v0.3)