feat(http): calculate updates' and uuids' dbs size

This commit is contained in:
Alexey Shekhirin
2021-04-09 15:41:24 +03:00
parent ae1655586c
commit adfdb99abc
17 changed files with 121 additions and 25 deletions

View File

@ -1,14 +1,14 @@
use std::collections::HashMap;
use std::ops::Deref;
use std::sync::Arc;
use chrono::{DateTime, Utc};
use sha2::Digest;
use crate::index::Settings;
use crate::index_controller::{IndexController, IndexStats};
use crate::index_controller::{IndexMetadata, IndexSettings};
use crate::option::Opt;
use std::collections::HashMap;
use chrono::{DateTime, Utc};
pub mod search;
mod updates;
@ -119,15 +119,22 @@ impl Data {
pub async fn get_stats(&self) -> anyhow::Result<Stats> {
let mut stats = Stats::default();
stats.database_size += self.index_controller.get_uuids_size().await?;
for index in self.index_controller.list_indexes().await? {
let index_stats = self.index_controller.get_stats(index.uid.clone()).await?;
stats.database_size += index_stats.size;
stats.database_size += self
.index_controller
.get_updates_size(index.uid.clone())
.await?;
stats.last_update = Some(match stats.last_update {
Some(last_update) => last_update.max(index.meta.updated_at),
None => index.meta.updated_at,
});
stats.indexes.insert(index.uid, index_stats);
}