From fad8b55d81713f5d8a88e16ac546e9cf97b3465b Mon Sep 17 00:00:00 2001 From: rito528 <39003544+rito528@users.noreply.github.com> Date: Wed, 25 Sep 2024 23:32:45 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20=E6=A4=9C=E7=B4=A2=E3=81=99?= =?UTF-8?q?=E3=82=8B=E3=81=A8=E3=81=8D=E3=81=AB=E3=82=AF=E3=82=A8=E3=83=AA?= =?UTF-8?q?=E3=81=AE=E6=89=80=E6=9C=89=E6=A8=A9=E3=82=92=E8=A6=81=E6=B1=82?= =?UTF-8?q?=E3=81=97=E3=81=AA=E3=81=84=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/repository/search_repository.rs | 12 +++++----- .../infra/resource/src/database/components.rs | 12 +++++----- server/infra/resource/src/database/search.rs | 24 +++++++++---------- .../src/repository/search_repository_impl.rs | 12 +++++----- server/usecase/src/search.rs | 12 +++++----- 5 files changed, 36 insertions(+), 36 deletions(-) diff --git a/server/domain/src/repository/search_repository.rs b/server/domain/src/repository/search_repository.rs index fc7f6813..79e06ae9 100644 --- a/server/domain/src/repository/search_repository.rs +++ b/server/domain/src/repository/search_repository.rs @@ -10,10 +10,10 @@ use crate::{ #[automock] #[async_trait] pub trait SearchRepository: Send + Sync + 'static { - async fn search_users(&self, query: String) -> Result, Error>; - async fn search_forms(&self, query: String) -> Result, Error>; - async fn search_labels_for_forms(&self, query: String) -> Result, Error>; - async fn search_labels_for_answers(&self, query: String) -> Result, Error>; - async fn search_answers(&self, query: String) -> Result, Error>; - async fn search_comments(&self, query: String) -> Result, Error>; + async fn search_users(&self, query: &str) -> Result, Error>; + async fn search_forms(&self, query: &str) -> Result, Error>; + async fn search_labels_for_forms(&self, query: &str) -> Result, Error>; + async fn search_labels_for_answers(&self, query: &str) -> Result, Error>; + async fn search_answers(&self, query: &str) -> Result, Error>; + async fn search_comments(&self, query: &str) -> Result, Error>; } diff --git a/server/infra/resource/src/database/components.rs b/server/infra/resource/src/database/components.rs index 2ee76d37..7ac6b392 100644 --- a/server/infra/resource/src/database/components.rs +++ b/server/infra/resource/src/database/components.rs @@ -120,10 +120,10 @@ pub trait UserDatabase: Send + Sync { #[automock] #[async_trait] pub trait SearchDatabase: Send + Sync { - async fn search_users(&self, query: String) -> Result, InfraError>; - async fn search_forms(&self, query: String) -> Result, InfraError>; - async fn search_labels_for_forms(&self, query: String) -> Result, InfraError>; - async fn search_labels_for_answers(&self, query: String) -> Result, InfraError>; - async fn search_answers(&self, query: String) -> Result, InfraError>; - async fn search_comments(&self, query: String) -> Result, InfraError>; + async fn search_users(&self, query: &str) -> Result, InfraError>; + async fn search_forms(&self, query: &str) -> Result, InfraError>; + async fn search_labels_for_forms(&self, query: &str) -> Result, InfraError>; + async fn search_labels_for_answers(&self, query: &str) -> Result, InfraError>; + async fn search_answers(&self, query: &str) -> Result, InfraError>; + async fn search_comments(&self, query: &str) -> Result, InfraError>; } diff --git a/server/infra/resource/src/database/search.rs b/server/infra/resource/src/database/search.rs index 732d9ff2..d8ba1e61 100644 --- a/server/infra/resource/src/database/search.rs +++ b/server/infra/resource/src/database/search.rs @@ -11,12 +11,12 @@ use crate::database::{components::SearchDatabase, connection::ConnectionPool}; #[async_trait] impl SearchDatabase for ConnectionPool { - async fn search_users(&self, query: String) -> Result, InfraError> { + async fn search_users(&self, query: &str) -> Result, InfraError> { Ok(self .meilisearch_client .index("users") .search() - .with_query(&query) + .with_query(query) .with_attributes_to_highlight(Selectors::All) .execute::() .await? @@ -26,12 +26,12 @@ impl SearchDatabase for ConnectionPool { .collect_vec()) } - async fn search_forms(&self, query: String) -> Result, InfraError> { + async fn search_forms(&self, query: &str) -> Result, InfraError> { Ok(self .meilisearch_client .index("form_meta_data") .search() - .with_query(query.as_str()) + .with_query(query) .with_attributes_to_highlight(Selectors::All) .execute::
() .await? @@ -41,12 +41,12 @@ impl SearchDatabase for ConnectionPool { .collect_vec()) } - async fn search_labels_for_forms(&self, query: String) -> Result, InfraError> { + async fn search_labels_for_forms(&self, query: &str) -> Result, InfraError> { Ok(self .meilisearch_client .index("label_for_forms") .search() - .with_query(query.as_str()) + .with_query(query) .with_attributes_to_highlight(Selectors::All) .execute::