From 73edc7dffad96099788d49bbfbd4b8f9f66b3457 Mon Sep 17 00:00:00 2001 From: Max Karpawich Date: Tue, 6 Apr 2021 21:06:44 -0400 Subject: [PATCH] feat: use report count estimates --- lib/analytics/stats-queryer.js | 2 +- lib/database.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/analytics/stats-queryer.js b/lib/analytics/stats-queryer.js index 6018576be..1a61adce1 100644 --- a/lib/analytics/stats-queryer.js +++ b/lib/analytics/stats-queryer.js @@ -25,7 +25,7 @@ StatsQueryer.prototype.count = function(type, callback) { StatsQueryer.prototype._countReports = function(query, callback) { query || (query = {}); - Report.countDocuments(query, callback); + Report.estimatedDocumentCount(query, callback); }; StatsQueryer.prototype._countIncidents = function(query, callback) { diff --git a/lib/database.js b/lib/database.js index 871fb8291..15199770e 100644 --- a/lib/database.js +++ b/lib/database.js @@ -38,7 +38,7 @@ mongoose.Model.findPage = function(filters, page, options, callback) { // execute count and find in parallel fashion to avoid waiting for each other async.parallel([ - model.countDocuments.bind(model, filters), + model.estimatedDocumentCount.bind(model, filters), function(callback) { var query = model.find(filters, null, options); if (populate) query = query.populate(populate);