Stats for the newest 2 tables

This commit is contained in:
Mike Dilger 2024-09-22 07:33:10 +12:00
parent 17ea337ef5
commit 10f44b4e5f
3 changed files with 20 additions and 2 deletions

View File

@ -1,7 +1,7 @@
use super::GossipUi;
use eframe::egui;
use egui::{Context, Ui};
use gossip_lib::{PersonTable, Table, GLOBALS};
use gossip_lib::{FollowingsTable, PersonTable, Table, GLOBALS};
use humansize::{format_size, DECIMAL};
use std::sync::atomic::Ordering;
@ -141,5 +141,17 @@ pub(super) fn update(app: &mut GossipUi, _ctx: &Context, _frame: &mut eframe::Fr
GLOBALS.db().get_nip46servers_len().unwrap_or(0)
));
ui.add_space(6.0);
ui.label(format!(
"Followings: {} records",
FollowingsTable::num_records().unwrap_or(0)
));
ui.add_space(6.0);
ui.label(format!(
"WoT: {} records",
GLOBALS.db().get_wot_len().unwrap_or(0)
));
ui.add_space(6.0);
});
}

View File

@ -158,7 +158,7 @@ pub use status::StatusQueue;
mod storage;
pub use storage::types::*;
pub use storage::{PersonTable, Storage, Table};
pub use storage::{FollowingsTable, PersonTable, Storage, Table};
mod tasks;

View File

@ -360,6 +360,12 @@ impl Storage {
Ok(self.db_person_lists()?.len(&txn)?)
}
/// The number of records in the wot table
pub fn get_wot_len(&self) -> Result<u64, Error> {
let txn = self.env.read_txn()?;
Ok(self.db_wot()?.len(&txn)?)
}
// General key-value functions --------------------------------------------------
pub fn force_migration_level(&self, level: u32) -> Result<(), Error> {