fix admin query timers not covering full iteration
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
0171262581
commit
a1ced0a56f
4 changed files with 27 additions and 57 deletions
|
@ -22,9 +22,8 @@ pub(super) async fn presence(subcommand: Presence) -> Result<RoomMessageEventCon
|
||||||
} => {
|
} => {
|
||||||
let timer = tokio::time::Instant::now();
|
let timer = tokio::time::Instant::now();
|
||||||
let results = services().presence.db.presence_since(since);
|
let results = services().presence.db.presence_since(since);
|
||||||
let query_time = timer.elapsed();
|
|
||||||
|
|
||||||
let presence_since: Vec<(_, _, _)> = results.collect();
|
let presence_since: Vec<(_, _, _)> = results.collect();
|
||||||
|
let query_time = timer.elapsed();
|
||||||
|
|
||||||
Ok(RoomMessageEventContent::notice_markdown(format!(
|
Ok(RoomMessageEventContent::notice_markdown(format!(
|
||||||
"Query completed in {query_time:?}:\n\n```rs\n{presence_since:#?}\n```"
|
"Query completed in {query_time:?}:\n\n```rs\n{presence_since:#?}\n```"
|
||||||
|
|
|
@ -22,9 +22,8 @@ pub(super) async fn room_alias(subcommand: RoomAlias) -> Result<RoomMessageEvent
|
||||||
} => {
|
} => {
|
||||||
let timer = tokio::time::Instant::now();
|
let timer = tokio::time::Instant::now();
|
||||||
let results = services().rooms.alias.local_aliases_for_room(&room_id);
|
let results = services().rooms.alias.local_aliases_for_room(&room_id);
|
||||||
let query_time = timer.elapsed();
|
|
||||||
|
|
||||||
let aliases: Vec<_> = results.collect();
|
let aliases: Vec<_> = results.collect();
|
||||||
|
let query_time = timer.elapsed();
|
||||||
|
|
||||||
Ok(RoomMessageEventContent::notice_markdown(format!(
|
Ok(RoomMessageEventContent::notice_markdown(format!(
|
||||||
"Query completed in {query_time:?}:\n\n```rs\n{aliases:#?}\n```"
|
"Query completed in {query_time:?}:\n\n```rs\n{aliases:#?}\n```"
|
||||||
|
@ -33,9 +32,8 @@ pub(super) async fn room_alias(subcommand: RoomAlias) -> Result<RoomMessageEvent
|
||||||
RoomAlias::AllLocalAliases => {
|
RoomAlias::AllLocalAliases => {
|
||||||
let timer = tokio::time::Instant::now();
|
let timer = tokio::time::Instant::now();
|
||||||
let results = services().rooms.alias.all_local_aliases();
|
let results = services().rooms.alias.all_local_aliases();
|
||||||
let query_time = timer.elapsed();
|
|
||||||
|
|
||||||
let aliases: Vec<_> = results.collect();
|
let aliases: Vec<_> = results.collect();
|
||||||
|
let query_time = timer.elapsed();
|
||||||
|
|
||||||
Ok(RoomMessageEventContent::notice_markdown(format!(
|
Ok(RoomMessageEventContent::notice_markdown(format!(
|
||||||
"Query completed in {query_time:?}:\n\n```rs\n{aliases:#?}\n```"
|
"Query completed in {query_time:?}:\n\n```rs\n{aliases:#?}\n```"
|
||||||
|
|
|
@ -9,9 +9,8 @@ pub(super) async fn sending(subcommand: Sending) -> Result<RoomMessageEventConte
|
||||||
Sending::ActiveRequests => {
|
Sending::ActiveRequests => {
|
||||||
let timer = tokio::time::Instant::now();
|
let timer = tokio::time::Instant::now();
|
||||||
let results = services().sending.db.active_requests();
|
let results = services().sending.db.active_requests();
|
||||||
let query_time = timer.elapsed();
|
|
||||||
|
|
||||||
let active_requests: Result<Vec<(_, _, _)>> = results.collect();
|
let active_requests: Result<Vec<(_, _, _)>> = results.collect();
|
||||||
|
let query_time = timer.elapsed();
|
||||||
|
|
||||||
Ok(RoomMessageEventContent::notice_markdown(format!(
|
Ok(RoomMessageEventContent::notice_markdown(format!(
|
||||||
"Query completed in {query_time:?}:\n\n```rs\n{active_requests:#?}\n```"
|
"Query completed in {query_time:?}:\n\n```rs\n{active_requests:#?}\n```"
|
||||||
|
@ -29,8 +28,8 @@ pub(super) async fn sending(subcommand: Sending) -> Result<RoomMessageEventConte
|
||||||
--help for more details.",
|
--help for more details.",
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
let timer = tokio::time::Instant::now();
|
||||||
let (results, query_time) = match (appservice_id, server_name, user_id, push_key) {
|
let results = match (appservice_id, server_name, user_id, push_key) {
|
||||||
(Some(appservice_id), None, None, None) => {
|
(Some(appservice_id), None, None, None) => {
|
||||||
if appservice_id.is_empty() {
|
if appservice_id.is_empty() {
|
||||||
return Ok(RoomMessageEventContent::text_plain(
|
return Ok(RoomMessageEventContent::text_plain(
|
||||||
|
@ -39,25 +38,15 @@ pub(super) async fn sending(subcommand: Sending) -> Result<RoomMessageEventConte
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
let timer = tokio::time::Instant::now();
|
services()
|
||||||
let results = services()
|
|
||||||
.sending
|
.sending
|
||||||
.db
|
.db
|
||||||
.queued_requests(&Destination::Appservice(appservice_id));
|
.queued_requests(&Destination::Appservice(appservice_id))
|
||||||
let query_time = timer.elapsed();
|
|
||||||
|
|
||||||
(results, query_time)
|
|
||||||
},
|
|
||||||
(None, Some(server_name), None, None) => {
|
|
||||||
let timer = tokio::time::Instant::now();
|
|
||||||
let results = services()
|
|
||||||
.sending
|
|
||||||
.db
|
|
||||||
.queued_requests(&Destination::Normal(server_name.into()));
|
|
||||||
let query_time = timer.elapsed();
|
|
||||||
|
|
||||||
(results, query_time)
|
|
||||||
},
|
},
|
||||||
|
(None, Some(server_name), None, None) => services()
|
||||||
|
.sending
|
||||||
|
.db
|
||||||
|
.queued_requests(&Destination::Normal(server_name.into())),
|
||||||
(None, None, Some(user_id), Some(push_key)) => {
|
(None, None, Some(user_id), Some(push_key)) => {
|
||||||
if push_key.is_empty() {
|
if push_key.is_empty() {
|
||||||
return Ok(RoomMessageEventContent::text_plain(
|
return Ok(RoomMessageEventContent::text_plain(
|
||||||
|
@ -66,14 +55,10 @@ pub(super) async fn sending(subcommand: Sending) -> Result<RoomMessageEventConte
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
let timer = tokio::time::Instant::now();
|
services()
|
||||||
let results = services()
|
|
||||||
.sending
|
.sending
|
||||||
.db
|
.db
|
||||||
.queued_requests(&Destination::Push(user_id.into(), push_key));
|
.queued_requests(&Destination::Push(user_id.into(), push_key))
|
||||||
let query_time = timer.elapsed();
|
|
||||||
|
|
||||||
(results, query_time)
|
|
||||||
},
|
},
|
||||||
(Some(_), Some(_), Some(_), Some(_)) => {
|
(Some(_), Some(_), Some(_), Some(_)) => {
|
||||||
return Ok(RoomMessageEventContent::text_plain(
|
return Ok(RoomMessageEventContent::text_plain(
|
||||||
|
@ -90,6 +75,7 @@ pub(super) async fn sending(subcommand: Sending) -> Result<RoomMessageEventConte
|
||||||
};
|
};
|
||||||
|
|
||||||
let queued_requests = results.collect::<Result<Vec<(_, _)>>>();
|
let queued_requests = results.collect::<Result<Vec<(_, _)>>>();
|
||||||
|
let query_time = timer.elapsed();
|
||||||
|
|
||||||
Ok(RoomMessageEventContent::notice_markdown(format!(
|
Ok(RoomMessageEventContent::notice_markdown(format!(
|
||||||
"Query completed in {query_time:?}:\n\n```rs\n{queued_requests:#?}\n```"
|
"Query completed in {query_time:?}:\n\n```rs\n{queued_requests:#?}\n```"
|
||||||
|
@ -108,7 +94,8 @@ pub(super) async fn sending(subcommand: Sending) -> Result<RoomMessageEventConte
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
let (results, query_time) = match (appservice_id, server_name, user_id, push_key) {
|
let timer = tokio::time::Instant::now();
|
||||||
|
let results = match (appservice_id, server_name, user_id, push_key) {
|
||||||
(Some(appservice_id), None, None, None) => {
|
(Some(appservice_id), None, None, None) => {
|
||||||
if appservice_id.is_empty() {
|
if appservice_id.is_empty() {
|
||||||
return Ok(RoomMessageEventContent::text_plain(
|
return Ok(RoomMessageEventContent::text_plain(
|
||||||
|
@ -117,25 +104,15 @@ pub(super) async fn sending(subcommand: Sending) -> Result<RoomMessageEventConte
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
let timer = tokio::time::Instant::now();
|
services()
|
||||||
let results = services()
|
|
||||||
.sending
|
.sending
|
||||||
.db
|
.db
|
||||||
.active_requests_for(&Destination::Appservice(appservice_id));
|
.active_requests_for(&Destination::Appservice(appservice_id))
|
||||||
let query_time = timer.elapsed();
|
|
||||||
|
|
||||||
(results, query_time)
|
|
||||||
},
|
|
||||||
(None, Some(server_name), None, None) => {
|
|
||||||
let timer = tokio::time::Instant::now();
|
|
||||||
let results = services()
|
|
||||||
.sending
|
|
||||||
.db
|
|
||||||
.active_requests_for(&Destination::Normal(server_name.into()));
|
|
||||||
let query_time = timer.elapsed();
|
|
||||||
|
|
||||||
(results, query_time)
|
|
||||||
},
|
},
|
||||||
|
(None, Some(server_name), None, None) => services()
|
||||||
|
.sending
|
||||||
|
.db
|
||||||
|
.active_requests_for(&Destination::Normal(server_name.into())),
|
||||||
(None, None, Some(user_id), Some(push_key)) => {
|
(None, None, Some(user_id), Some(push_key)) => {
|
||||||
if push_key.is_empty() {
|
if push_key.is_empty() {
|
||||||
return Ok(RoomMessageEventContent::text_plain(
|
return Ok(RoomMessageEventContent::text_plain(
|
||||||
|
@ -144,14 +121,10 @@ pub(super) async fn sending(subcommand: Sending) -> Result<RoomMessageEventConte
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
let timer = tokio::time::Instant::now();
|
services()
|
||||||
let results = services()
|
|
||||||
.sending
|
.sending
|
||||||
.db
|
.db
|
||||||
.active_requests_for(&Destination::Push(user_id.into(), push_key));
|
.active_requests_for(&Destination::Push(user_id.into(), push_key))
|
||||||
let query_time = timer.elapsed();
|
|
||||||
|
|
||||||
(results, query_time)
|
|
||||||
},
|
},
|
||||||
(Some(_), Some(_), Some(_), Some(_)) => {
|
(Some(_), Some(_), Some(_), Some(_)) => {
|
||||||
return Ok(RoomMessageEventContent::text_plain(
|
return Ok(RoomMessageEventContent::text_plain(
|
||||||
|
@ -168,6 +141,7 @@ pub(super) async fn sending(subcommand: Sending) -> Result<RoomMessageEventConte
|
||||||
};
|
};
|
||||||
|
|
||||||
let active_requests = results.collect::<Result<Vec<(_, _)>>>();
|
let active_requests = results.collect::<Result<Vec<(_, _)>>>();
|
||||||
|
let query_time = timer.elapsed();
|
||||||
|
|
||||||
Ok(RoomMessageEventContent::notice_markdown(format!(
|
Ok(RoomMessageEventContent::notice_markdown(format!(
|
||||||
"Query completed in {query_time:?}:\n\n```rs\n{active_requests:#?}\n```"
|
"Query completed in {query_time:?}:\n\n```rs\n{active_requests:#?}\n```"
|
||||||
|
|
|
@ -9,9 +9,8 @@ pub(super) async fn users(subcommand: Users) -> Result<RoomMessageEventContent>
|
||||||
Users::Iter => {
|
Users::Iter => {
|
||||||
let timer = tokio::time::Instant::now();
|
let timer = tokio::time::Instant::now();
|
||||||
let results = services().users.db.iter();
|
let results = services().users.db.iter();
|
||||||
let query_time = timer.elapsed();
|
|
||||||
|
|
||||||
let users = results.collect::<Vec<_>>();
|
let users = results.collect::<Vec<_>>();
|
||||||
|
let query_time = timer.elapsed();
|
||||||
|
|
||||||
Ok(RoomMessageEventContent::notice_markdown(format!(
|
Ok(RoomMessageEventContent::notice_markdown(format!(
|
||||||
"Query completed in {query_time:?}:\n\n```rs\n{users:#?}\n```"
|
"Query completed in {query_time:?}:\n\n```rs\n{users:#?}\n```"
|
||||||
|
|
Loading…
Add table
Reference in a new issue