From f1163f5ff443f29f7e0f107a0ffb63762353453e Mon Sep 17 00:00:00 2001 From: rito528 <39003544+rito528@users.noreply.github.com> Date: Wed, 25 Sep 2024 23:14:41 +0900 Subject: [PATCH 1/5] =?UTF-8?q?chore:=20meilisync=20=E3=81=AE=E5=90=8C?= =?UTF-8?q?=E6=9C=9F=E5=AF=BE=E8=B1=A1=E3=83=86=E3=83=BC=E3=83=96=E3=83=AB?= =?UTF-8?q?=E3=81=AB=20form=5Fanswer=5Fcomments=20=E3=82=92=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker/meilisync/config.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docker/meilisync/config.yml b/docker/meilisync/config.yml index efacc1a5..86d568ca 100644 --- a/docker/meilisync/config.yml +++ b/docker/meilisync/config.yml @@ -27,4 +27,5 @@ sync: full: true - table: users full: true - + - table: form_answer_comments + full: true From 41ced3fa978bd640f336707b362266f11987f1ee Mon Sep 17 00:00:00 2001 From: rito528 <39003544+rito528@users.noreply.github.com> Date: Wed, 25 Sep 2024 23:26:04 +0900 Subject: [PATCH 2/5] =?UTF-8?q?feat:=20Comment=20=E3=81=AB=20answer=5Fid?= =?UTF-8?q?=20=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/domain/src/form/models.rs | 1 + server/infra/resource/src/database/form.rs | 3 +++ server/infra/resource/src/dto.rs | 3 +++ server/presentation/src/form_handler.rs | 1 + 4 files changed, 8 insertions(+) diff --git a/server/domain/src/form/models.rs b/server/domain/src/form/models.rs index 38ae8d2d..514418ab 100644 --- a/server/domain/src/form/models.rs +++ b/server/domain/src/form/models.rs @@ -283,6 +283,7 @@ pub type CommentId = types::Id; #[derive(Serialize, Deserialize, Debug, PartialEq)] pub struct Comment { + pub answer_id: AnswerId, pub comment_id: CommentId, pub content: String, pub timestamp: DateTime, diff --git a/server/infra/resource/src/database/form.rs b/server/infra/resource/src/database/form.rs index a5d39bf7..98d18804 100644 --- a/server/infra/resource/src/database/form.rs +++ b/server/infra/resource/src/database/form.rs @@ -603,6 +603,7 @@ impl FormDatabase for ConnectionPool { iter() .map(|rs| { Ok::(CommentDto { + answer_id: rs.try_get("", "answer_id")?, comment_id: rs.try_get("", "comment_id")?, content: rs.try_get("", "content")?, timestamp: rs.try_get("", "timestamp")?, @@ -712,6 +713,7 @@ impl FormDatabase for ConnectionPool { }) .map(|rs| { Ok::(CommentDto { + answer_id: rs.try_get("", "answer_id")?, comment_id: rs.try_get("", "comment_id")?, content: rs.try_get("", "content")?, timestamp: rs.try_get("", "timestamp")?, @@ -812,6 +814,7 @@ impl FormDatabase for ConnectionPool { }) .map(|rs| { Ok::(CommentDto { + answer_id: rs.try_get("", "answer_id")?, comment_id: rs.try_get("", "comment_id")?, content: rs.try_get("", "content")?, timestamp: rs.try_get("", "timestamp")?, diff --git a/server/infra/resource/src/dto.rs b/server/infra/resource/src/dto.rs index fd24b9e3..e105c6a5 100644 --- a/server/infra/resource/src/dto.rs +++ b/server/infra/resource/src/dto.rs @@ -174,6 +174,7 @@ impl TryFrom for User { } pub struct CommentDto { + pub answer_id: i32, pub comment_id: i32, pub content: String, pub timestamp: DateTime, @@ -185,6 +186,7 @@ impl TryFrom for domain::form::models::Comment { fn try_from( CommentDto { + answer_id, comment_id, content, timestamp, @@ -192,6 +194,7 @@ impl TryFrom for domain::form::models::Comment { }: CommentDto, ) -> Result { Ok(domain::form::models::Comment { + answer_id: answer_id.into(), comment_id: comment_id.into(), content, timestamp, diff --git a/server/presentation/src/form_handler.rs b/server/presentation/src/form_handler.rs index b8bfc924..50d96438 100644 --- a/server/presentation/src/form_handler.rs +++ b/server/presentation/src/form_handler.rs @@ -306,6 +306,7 @@ pub async fn post_form_comment( let comment = Comment { // NOTE: コメントはデータベースで insert した後に id が振られるのでデフォルト値を入れておく comment_id: Default::default(), + answer_id: comment_schema.answer_id, content: comment_schema.content, timestamp: chrono::Utc::now(), commented_by: user, From 53ab2b70a50fec97fe610b8f25cd1345317c01d0 Mon Sep 17 00:00:00 2001 From: rito528 <39003544+rito528@users.noreply.github.com> Date: Wed, 25 Sep 2024 23:29:41 +0900 Subject: [PATCH 3/5] =?UTF-8?q?feat:=20=E6=A8=AA=E6=96=AD=E6=A4=9C?= =?UTF-8?q?=E7=B4=A2=E3=82=A8=E3=83=B3=E3=83=89=E3=83=9D=E3=82=A4=E3=83=B3?= =?UTF-8?q?=E3=83=88=E3=81=A7=E3=82=B3=E3=83=A1=E3=83=B3=E3=83=88=E3=82=82?= =?UTF-8?q?=E8=BF=94=E3=81=99=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/src/repository/search_repository.rs | 3 ++- server/domain/src/search/models.rs | 3 ++- .../infra/resource/src/database/components.rs | 1 + server/infra/resource/src/database/search.rs | 17 ++++++++++++++++- .../src/repository/search_repository_impl.rs | 10 +++++++++- server/usecase/src/search.rs | 6 ++++-- 6 files changed, 34 insertions(+), 6 deletions(-) diff --git a/server/domain/src/repository/search_repository.rs b/server/domain/src/repository/search_repository.rs index d119fd47..fc7f6813 100644 --- a/server/domain/src/repository/search_repository.rs +++ b/server/domain/src/repository/search_repository.rs @@ -3,7 +3,7 @@ use errors::Error; use mockall::automock; use crate::{ - form::models::{Answer, Form, Label}, + form::models::{Answer, Comment, Form, Label}, user::models::User, }; @@ -15,4 +15,5 @@ pub trait SearchRepository: Send + Sync + 'static { 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>; } diff --git a/server/domain/src/search/models.rs b/server/domain/src/search/models.rs index 4a7e9229..ed5e403c 100644 --- a/server/domain/src/search/models.rs +++ b/server/domain/src/search/models.rs @@ -1,7 +1,7 @@ use serde::{Deserialize, Serialize}; use crate::{ - form::models::{Answer, Form, Label}, + form::models::{Answer, Comment, Form, Label}, user::models::User, }; @@ -12,6 +12,7 @@ pub struct CrossSearchResult { pub answers: Vec, pub label_for_forms: Vec