From 6b4a0b92f8c63c88000c716127951732ed6cc737 Mon Sep 17 00:00:00 2001 From: fmelihh Date: Sun, 7 Jul 2024 21:50:59 +0300 Subject: [PATCH] feat: created comments orm object --- .../app/features/comments/db/model.py | 13 +++++++++++-- tests/app/domain/comments/test_mapper.py | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/recommendation_engine/app/features/comments/db/model.py b/src/recommendation_engine/app/features/comments/db/model.py index e8c4f3c..2eafba4 100644 --- a/src/recommendation_engine/app/features/comments/db/model.py +++ b/src/recommendation_engine/app/features/comments/db/model.py @@ -1,5 +1,6 @@ +import datetime from clickhouse_sqlalchemy import engines -from sqlalchemy import Column, Integer, String, Date +from sqlalchemy import Column, Integer, String, DateTime, Array from ....core.database.clickhouse import ClickhouseBase @@ -7,7 +8,15 @@ class CommentsModel(ClickhouseBase): __tablename__ = "comments" + rating: int = Column(Integer) + comment: str = Column(String) + comment_id: str = Column(String) + replies: list[str] = Column(Array(String)) + like_count: int = Column(Integer) + created_at: datetime.datetime | None = Column(DateTime, nullable=True) + updated_at: datetime.datetime | None = Column(DateTime, nullable=True) + __table_args__ = ( - engines.MergeTree(order_by=["id"]), + engines.MergeTree(order_by=["created_at"]), {"schema": "default"}, ) diff --git a/tests/app/domain/comments/test_mapper.py b/tests/app/domain/comments/test_mapper.py index 4b67ab4..3198b7c 100644 --- a/tests/app/domain/comments/test_mapper.py +++ b/tests/app/domain/comments/test_mapper.py @@ -37,7 +37,7 @@ def test_yemeksepeti_mapper(): rating=[ {"topic": "overall", "score": 1}, {"topic": "restaurant_food", "score": 1}, - {"topic": "rider", "score": 1} + {"topic": "rider", "score": 1}, ], comment_like_count=2, product_variation=[],