Files
continuwuity/src/admin/query/appservice.rs
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

43 lines
1.3 KiB
Rust
Raw Normal View History

2024-07-27 00:11:41 +00:00
use clap::Subcommand;
2024-12-14 21:58:01 -05:00
use conduwuit::Result;
2025-04-07 03:28:51 +00:00
use futures::TryStreamExt;
use crate::Context;
2024-07-27 00:11:41 +00:00
#[derive(Debug, Subcommand)]
/// All the getters and iterators from src/database/key_value/appservice.rs
2025-05-24 00:28:09 +01:00
pub enum AppserviceCommand {
/// Gets the appservice registration info/details from the ID as a string
2024-07-27 00:11:41 +00:00
GetRegistration {
/// Appservice registration ID
appservice_id: String,
2024-07-27 00:11:41 +00:00
},
/// Gets all appservice registrations with their ID and registration info
2024-07-27 00:11:41 +00:00
All,
}
/// All the getters and iterators from src/database/key_value/appservice.rs
pub(super) async fn process(subcommand: AppserviceCommand, context: &Context<'_>) -> Result {
2024-07-27 00:11:41 +00:00
let services = context.services;
match subcommand {
| AppserviceCommand::GetRegistration { appservice_id } => {
let timer = tokio::time::Instant::now();
let results = services.appservice.get_registration(&appservice_id).await;
2024-08-08 17:18:30 +00:00
2024-04-22 18:53:40 -04:00
let query_time = timer.elapsed();
2025-01-04 16:57:07 +00:00
write!(context, "Query completed in {query_time:?}:\n\n```rs\n{results:#?}\n```")
2024-04-22 18:53:40 -04:00
},
| AppserviceCommand::All => {
2024-04-22 18:53:40 -04:00
let timer = tokio::time::Instant::now();
2025-04-07 03:28:51 +00:00
let results: Vec<_> = services.appservice.iter_db_ids().try_collect().await?;
let query_time = timer.elapsed();
2025-01-04 16:57:07 +00:00
write!(context, "Query completed in {query_time:?}:\n\n```rs\n{results:#?}\n```")
},
}
2025-01-04 16:57:07 +00:00
.await
}