Commit cca1ded9 by James Delonay

taking query into account when calculating numDocuments and totalOccurences for…

taking query into account when calculating numDocuments and totalOccurences for correct reporting in case where query is used.
parent a1a10a63
...@@ -189,7 +189,7 @@ for(var key in interimResults){ ...@@ -189,7 +189,7 @@ for(var key in interimResults){
varietyResults.push(newEntry); varietyResults.push(newEntry);
} }
var numDocuments = db[collection].count(); var numDocuments = db[collection].count(query);
// We throw away keys which end in an array index, since they are not useful // We throw away keys which end in an array index, since they are not useful
// for our analysis. (We still keep the key of their parent array, though.) -JC // for our analysis. (We still keep the key of their parent array, though.) -JC
...@@ -207,7 +207,7 @@ var map = function(item) { ...@@ -207,7 +207,7 @@ var map = function(item) {
} }
// we don't need to set it if limit isn't being used. (it's set above.) // we don't need to set it if limit isn't being used. (it's set above.)
if(limit < numDocuments) { if(limit < numDocuments) {
var existsQuery = {}; var existsQuery = query;
existsQuery[keyName] = {$exists: true}; existsQuery[keyName] = {$exists: true};
item.totalOccurrences = db[collection].count(existsQuery); item.totalOccurrences = db[collection].count(existsQuery);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment