All checks were successful
actionlint check / actionlint check (pull_request) Successful in 7s
conventional pull request title check / conventional pull request title check (pull_request) Successful in 3s
GitLeaks check / GitLeaks check (pull_request) Successful in 14s
hadolint check / hadolint check (pull_request) Successful in 15s
conventional commit messages check / conventional commit messages check (pull_request) Successful in 7s
dotenv-linter check / dotenv-linter check (pull_request) Successful in 8s
htmlhint check / htmlhint check (pull_request) Successful in 20s
markdownlint check / markdownlint check (pull_request) Successful in 32s
Prettier check / Prettier check (pull_request) Successful in 33s
checkov check / checkov check (pull_request) Successful in 1m20s
ShellCheck check / ShellCheck check (pull_request) Successful in 30s
Stylelint check / Stylelint check (pull_request) Successful in 27s
yamllint check / yamllint check (pull_request) Successful in 26s
Rust check / Rust check (pull_request) Successful in 12m52s
27 lines
968 B
Rust
27 lines
968 B
Rust
use crate::query::{QueryErrors, QueryKey, QueryValue};
|
|
use crate::server::subtasks::get_subtasks_of_task;
|
|
use dioxus::prelude::ServerFnError;
|
|
use dioxus_query::prelude::{QueryResult, UseQuery, use_get_query};
|
|
|
|
pub(crate) fn use_subtasks_of_task_query(
|
|
task_id: i32,
|
|
) -> UseQuery<QueryValue, QueryErrors, QueryKey> {
|
|
use_get_query(
|
|
[QueryKey::SubtasksOfTaskId(task_id)],
|
|
fetch_subtasks_of_task,
|
|
)
|
|
}
|
|
|
|
async fn fetch_subtasks_of_task(keys: Vec<QueryKey>) -> QueryResult<QueryValue, QueryErrors> {
|
|
if let Some(QueryKey::SubtasksOfTaskId(task_id)) = keys.first() {
|
|
match get_subtasks_of_task(*task_id).await {
|
|
Ok(subtasks) => Ok(QueryValue::Subtasks(subtasks)),
|
|
Err(ServerFnError::WrappedServerError(errors)) => Err(QueryErrors::Error(errors)),
|
|
Err(error) => panic!("Unexpected error: {error:?}"),
|
|
}
|
|
.into()
|
|
} else {
|
|
panic!("Unexpected query keys: {keys:?}");
|
|
}
|
|
}
|