From 12d9e454dbdc24494c6cd7c29cdc88e23013c68b Mon Sep 17 00:00:00 2001 From: strawberry Date: Sun, 28 Jul 2024 17:11:31 -0400 Subject: [PATCH] display success/failure count in get-remote-pdu-list Signed-off-by: strawberry --- src/admin/debug/commands.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/admin/debug/commands.rs b/src/admin/debug/commands.rs index 1802357a..53f4cf64 100644 --- a/src/admin/debug/commands.rs +++ b/src/admin/debug/commands.rs @@ -149,23 +149,32 @@ pub(super) async fn get_remote_pdu_list( .filter_map(|pdu| EventId::parse(pdu).ok()) .collect::>(); + let mut failed_count: usize = 0; + let mut success_count: usize = 0; + for pdu in list { if force { if let Err(e) = self.get_remote_pdu(Box::from(pdu), server.clone()).await { + failed_count = failed_count.saturating_add(1); self.services .admin .send_message(RoomMessageEventContent::text_plain(format!( "Failed to get remote PDU, ignoring error: {e}" ))) .await; - warn!(%e, "Failed to get remote PDU, ignoring error"); + warn!("Failed to get remote PDU, ignoring error: {e}"); + } else { + success_count = success_count.saturating_add(1); } } else { self.get_remote_pdu(Box::from(pdu), server.clone()).await?; + success_count = success_count.saturating_add(1); } } - Ok(RoomMessageEventContent::text_plain("Fetched list of remote PDUs.")) + Ok(RoomMessageEventContent::text_plain(format!( + "Fetched {success_count} remote PDUs successfully with {failed_count} failures" + ))) } #[admin_command]