use raw database functions, not helper functions, for admin query command
the helper functions may do ad-hoc data manipulation Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
parent
e4a6a2325b
commit
b93215d7f2
2 changed files with 7 additions and 6 deletions
|
@ -26,12 +26,11 @@ use serde_json::value::to_raw_value;
|
||||||
use tokio::sync::Mutex;
|
use tokio::sync::Mutex;
|
||||||
use tracing::{error, warn};
|
use tracing::{error, warn};
|
||||||
|
|
||||||
use self::query::QueryCommand;
|
|
||||||
use super::pdu::PduBuilder;
|
use super::pdu::PduBuilder;
|
||||||
use crate::{
|
use crate::{
|
||||||
service::admin::{
|
service::admin::{
|
||||||
appservice::AppserviceCommand, debug::DebugCommand, federation::FederationCommand, media::MediaCommand,
|
appservice::AppserviceCommand, debug::DebugCommand, federation::FederationCommand, media::MediaCommand,
|
||||||
room::RoomCommand, server::ServerCommand, user::UserCommand,
|
query::QueryCommand, room::RoomCommand, server::ServerCommand, user::UserCommand,
|
||||||
},
|
},
|
||||||
services, Error, Result,
|
services, Error, Result,
|
||||||
};
|
};
|
||||||
|
|
|
@ -101,6 +101,7 @@ async fn account_data(subcommand: AccountData) -> Result<RoomMessageEventContent
|
||||||
let timer = tokio::time::Instant::now();
|
let timer = tokio::time::Instant::now();
|
||||||
let results = services()
|
let results = services()
|
||||||
.account_data
|
.account_data
|
||||||
|
.db
|
||||||
.changes_since(room_id.as_deref(), &user_id, since)?;
|
.changes_since(room_id.as_deref(), &user_id, since)?;
|
||||||
let query_time = timer.elapsed();
|
let query_time = timer.elapsed();
|
||||||
|
|
||||||
|
@ -120,6 +121,7 @@ async fn account_data(subcommand: AccountData) -> Result<RoomMessageEventContent
|
||||||
let timer = tokio::time::Instant::now();
|
let timer = tokio::time::Instant::now();
|
||||||
let results = services()
|
let results = services()
|
||||||
.account_data
|
.account_data
|
||||||
|
.db
|
||||||
.get(room_id.as_deref(), &user_id, kind)?;
|
.get(room_id.as_deref(), &user_id, kind)?;
|
||||||
let query_time = timer.elapsed();
|
let query_time = timer.elapsed();
|
||||||
|
|
||||||
|
@ -143,8 +145,8 @@ async fn appservice(subcommand: Appservice) -> Result<RoomMessageEventContent> {
|
||||||
let timer = tokio::time::Instant::now();
|
let timer = tokio::time::Instant::now();
|
||||||
let results = services()
|
let results = services()
|
||||||
.appservice
|
.appservice
|
||||||
.get_registration(appservice_id.as_ref())
|
.db
|
||||||
.await;
|
.get_registration(appservice_id.as_ref())?;
|
||||||
let query_time = timer.elapsed();
|
let query_time = timer.elapsed();
|
||||||
|
|
||||||
Ok(RoomMessageEventContent::text_html(
|
Ok(RoomMessageEventContent::text_html(
|
||||||
|
@ -165,7 +167,7 @@ async fn presence(subcommand: Presence) -> Result<RoomMessageEventContent> {
|
||||||
user_id,
|
user_id,
|
||||||
} => {
|
} => {
|
||||||
let timer = tokio::time::Instant::now();
|
let timer = tokio::time::Instant::now();
|
||||||
let results = services().presence.get_presence(&user_id)?;
|
let results = services().presence.db.get_presence(&user_id)?;
|
||||||
let query_time = timer.elapsed();
|
let query_time = timer.elapsed();
|
||||||
|
|
||||||
Ok(RoomMessageEventContent::text_html(
|
Ok(RoomMessageEventContent::text_html(
|
||||||
|
@ -180,7 +182,7 @@ async fn presence(subcommand: Presence) -> Result<RoomMessageEventContent> {
|
||||||
since,
|
since,
|
||||||
} => {
|
} => {
|
||||||
let timer = tokio::time::Instant::now();
|
let timer = tokio::time::Instant::now();
|
||||||
let results = services().presence.presence_since(since);
|
let results = services().presence.db.presence_since(since);
|
||||||
let query_time = timer.elapsed();
|
let query_time = timer.elapsed();
|
||||||
|
|
||||||
let presence_since: Vec<(_, _, _)> = results.collect();
|
let presence_since: Vec<(_, _, _)> = results.collect();
|
||||||
|
|
Loading…
Add table
Reference in a new issue