fix: allow disk use for stats

This commit is contained in:
Anna 2021-12-27 19:34:42 -05:00
parent 685703ea12
commit 88bfa7796b
1 changed files with 4 additions and 1 deletions

View File

@ -1,6 +1,7 @@
use anyhow::Result;
use chrono::{Duration, Utc};
use mongodb::bson::{Document, doc};
use mongodb::options::AggregateOptions;
use tokio_stream::StreamExt;
use crate::stats::Statistics;
use crate::web::State;
@ -125,7 +126,9 @@ pub async fn get_stats_seven_days(state: &State) -> Result<Statistics> {
async fn get_stats_internal(state: &State, docs: impl IntoIterator<Item = Document>) -> Result<Statistics> {
let mut cursor = state
.collection()
.aggregate(docs, None)
.aggregate(docs, Some(AggregateOptions::builder()
.allow_disk_use(true)
.build()))
.await?;
let doc = cursor.try_next().await?;
let doc = doc.ok_or_else(|| anyhow::anyhow!("missing document"))?;