Some checks failed
Checks / Prek / Check changed files (push) Successful in 1m0s
Documentation / Build and Deploy Documentation (push) Successful in 1m4s
Checks / Prek / Pre-commit & Formatting (push) Successful in 1m8s
Release Docker Image / Create Multi-arch Release Manifest (push) Has been cancelled
Release Docker Image / Build linux-amd64 (max-perf) (push) Has been cancelled
Release Docker Image / Build linux-arm64 (max-perf) (push) Has been cancelled
Release Docker Image / Create Max-Perf Manifest (push) Has been cancelled
Release Docker Image / Release Binaries (push) Has been cancelled
Release Docker Image / Mirror Images (push) Has been cancelled
Release Docker Image / Build linux-amd64 (release) (push) Has been cancelled
Checks / Prek / Clippy and Cargo Tests (push) Has been cancelled
Release Docker Image / Build linux-arm64 (release) (push) Has been cancelled
Reviewed-By: Ginger <ginger@gingershaped.computer> Reviewed-By: Jade <jade@ellis.link> Reviewed-By: Jacob Taylor <jacob@explodie.org>
47 lines
1.3 KiB
Rust
47 lines
1.3 KiB
Rust
use clap::Subcommand;
|
|
use conduwuit::Result;
|
|
|
|
use crate::Context;
|
|
|
|
#[derive(Debug, Subcommand)]
|
|
/// All the getters and iterators from src/database/key_value/globals.rs
|
|
pub enum GlobalsCommand {
|
|
DatabaseVersion,
|
|
|
|
CurrentCount,
|
|
|
|
LastCheckForAnnouncementsId,
|
|
}
|
|
|
|
/// All the getters and iterators from src/database/key_value/globals.rs
|
|
pub(super) async fn process(subcommand: GlobalsCommand, context: &Context<'_>) -> Result {
|
|
let services = context.services;
|
|
|
|
match subcommand {
|
|
| GlobalsCommand::DatabaseVersion => {
|
|
let timer = tokio::time::Instant::now();
|
|
let results = services.globals.db.database_version().await;
|
|
let query_time = timer.elapsed();
|
|
|
|
write!(context, "Query completed in {query_time:?}:\n\n```rs\n{results:#?}\n```")
|
|
},
|
|
| GlobalsCommand::CurrentCount => {
|
|
let timer = tokio::time::Instant::now();
|
|
let results = services.globals.db.current_count();
|
|
let query_time = timer.elapsed();
|
|
|
|
write!(context, "Query completed in {query_time:?}:\n\n```rs\n{results:#?}\n```")
|
|
},
|
|
| GlobalsCommand::LastCheckForAnnouncementsId => {
|
|
let timer = tokio::time::Instant::now();
|
|
let results = services
|
|
.announcements
|
|
.last_check_for_announcements_id()
|
|
.await;
|
|
let query_time = timer.elapsed();
|
|
|
|
write!(context, "Query completed in {query_time:?}:\n\n```rs\n{results:#?}\n```")
|
|
},
|
|
}
|
|
.await
|
|
}
|