add sending.rs to admin db query command

Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
strawberry 2024-04-21 15:00:54 -04:00 committed by June
parent 67b4f19c60
commit 9b7dab3a57
3 changed files with 40 additions and 1 deletions

View file

@ -0,0 +1,25 @@
use ruma::events::room::message::RoomMessageEventContent;
use super::Sending;
use crate::{services, Result};
/// All the getters and iterators in key_value/sending.rs
pub(super) async fn sending(subcommand: Sending) -> Result<RoomMessageEventContent> {
match subcommand {
Sending::ActiveRequests => {
let timer = tokio::time::Instant::now();
let results = services().sending.db.active_requests();
let query_time = timer.elapsed();
let active_requests: Result<Vec<(_, _, _)>> = results.collect();
Ok(RoomMessageEventContent::text_html(
format!("Query completed in {query_time:?}:\n\n```\n{:?}```", active_requests),
format!(
"<p>Query completed in {query_time:?}:</p>\n<pre><code>{:?}\n</code></pre>",
active_requests
),
))
},
}
}