From 10f44b4e5fa9cbe7055f814f4fedde7393f3e8b9 Mon Sep 17 00:00:00 2001 From: Mike Dilger Date: Sun, 22 Sep 2024 07:33:10 +1200 Subject: [PATCH] Stats for the newest 2 tables --- gossip-bin/src/ui/help/stats.rs | 14 +++++++++++++- gossip-lib/src/lib.rs | 2 +- gossip-lib/src/storage/mod.rs | 6 ++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/gossip-bin/src/ui/help/stats.rs b/gossip-bin/src/ui/help/stats.rs index 58cce323..8031264e 100644 --- a/gossip-bin/src/ui/help/stats.rs +++ b/gossip-bin/src/ui/help/stats.rs @@ -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); }); } diff --git a/gossip-lib/src/lib.rs b/gossip-lib/src/lib.rs index cf847638..4bc220f3 100644 --- a/gossip-lib/src/lib.rs +++ b/gossip-lib/src/lib.rs @@ -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; diff --git a/gossip-lib/src/storage/mod.rs b/gossip-lib/src/storage/mod.rs index d393865d..561ff2b5 100644 --- a/gossip-lib/src/storage/mod.rs +++ b/gossip-lib/src/storage/mod.rs @@ -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 { + 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> {