From d652f976b2c6fdda4fc8ccf2b8a3105c531a9251 Mon Sep 17 00:00:00 2001 From: fmelihh Date: Sun, 12 May 2024 14:19:15 +0300 Subject: [PATCH] feat: yemeksepeti comment value transform method was developed. --- .../app/domain/comments/entity/yemek_sepeti.py | 15 ++++++++++++++- .../comments/values/yemeksepeti/comment.py | 18 +++++++++--------- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/src/recommendation_engine/app/domain/comments/entity/yemek_sepeti.py b/src/recommendation_engine/app/domain/comments/entity/yemek_sepeti.py index 49618c4..ec48f41 100644 --- a/src/recommendation_engine/app/domain/comments/entity/yemek_sepeti.py +++ b/src/recommendation_engine/app/domain/comments/entity/yemek_sepeti.py @@ -78,7 +78,20 @@ def _iterate_over_comments(self) -> Generator[dict, None, None]: @staticmethod def transform_unstructured_data(record_value: dict) -> YemeksepetiCommentValue: - pass + values = dict() + values["comment_id"] = record_value.get("uuid") + values["created_at"] = record_value.get("createdAt") + values["updated_at"] = record_value.get("updatedAt") + values["comment"] = record_value.get("text") + values["reviewer_name"] = record_value.get("reviewerName") + values["reviewer_id"] = record_value.get("reviewerId") + values["rating"] = record_value.get("ratings") + values["comment_like_count"] = record_value.get("likeCount") + values["product_variation"] = record_value.get("productVariations") + values["replies"] = record_value.get("replies") + + comment_value = YemeksepetiCommentValue(**values) + return comment_value def process( self, process_limit: int | None = None diff --git a/src/recommendation_engine/app/domain/comments/values/yemeksepeti/comment.py b/src/recommendation_engine/app/domain/comments/values/yemeksepeti/comment.py index 4acc31b..d560cc4 100644 --- a/src/recommendation_engine/app/domain/comments/values/yemeksepeti/comment.py +++ b/src/recommendation_engine/app/domain/comments/values/yemeksepeti/comment.py @@ -10,13 +10,13 @@ @dataclass(frozen=True) class YemeksepetiCommentValue(CommentValue): - comment_id: str - created_at: datetime.datetime - updated_at: datetime.datetime - comment: str - reviewer_name: str - reviewer_id: str + comment_id: str | None + created_at: datetime.datetime | str | None + updated_at: datetime.datetime | str | None + comment: str | None + reviewer_name: str | None + reviewer_id: str | None rating: YemekSepetiRating | list[dict] | None - comment_like_count: int - product_variation: list[ProductVariation] | None - replies: list[YemeksepetiReplies] | None + comment_like_count: int | None + product_variation: list[ProductVariation] | list[dict] | None + replies: list[YemeksepetiReplies] | list[dict] | None