diff --git a/crates/application/src/search/execute.rs b/crates/application/src/search/execute.rs index 36de83e..de7c9e0 100644 --- a/crates/application/src/search/execute.rs +++ b/crates/application/src/search/execute.rs @@ -1,11 +1,15 @@ -use crate::context::AppContext; +use std::sync::Arc; use domain::{ errors::DomainError, models::{SearchQuery, SearchResults}, + ports::SearchPort, }; -pub async fn execute(ctx: &AppContext, query: SearchQuery) -> Result { - ctx.repos.search_port.search(&query).await +pub async fn execute( + search_port: Arc, + query: SearchQuery, +) -> Result { + search_port.search(&query).await } #[cfg(test)] diff --git a/crates/application/src/search/tests/execute.rs b/crates/application/src/search/tests/execute.rs index 10888b2..93a87d0 100644 --- a/crates/application/src/search/tests/execute.rs +++ b/crates/application/src/search/tests/execute.rs @@ -7,7 +7,7 @@ use crate::test_helpers::TestContextBuilder; async fn returns_empty_results() { let ctx = TestContextBuilder::new().build(); - let result = execute::execute(&ctx, SearchQuery::default()) + let result = execute::execute(ctx.repos.search_port.clone(), SearchQuery::default()) .await .unwrap(); diff --git a/crates/presentation/src/handlers/search.rs b/crates/presentation/src/handlers/search.rs index 75d3f71..fb140cf 100644 --- a/crates/presentation/src/handlers/search.rs +++ b/crates/presentation/src/handlers/search.rs @@ -45,7 +45,7 @@ pub async fn get_search( }, }; - match search_uc::execute(&state.app_ctx, query).await { + match search_uc::execute(state.app_ctx.repos.search_port.clone(), query).await { Ok(results) => axum::Json(SearchResponse { movies: PaginatedMovieHits { items: results