Skip to content

Commit

Permalink
feat: created comments orm object
Browse files Browse the repository at this point in the history
  • Loading branch information
fmelihh committed Jul 7, 2024
1 parent 24f92b7 commit 6b4a0b9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 11 additions & 2 deletions src/recommendation_engine/app/features/comments/db/model.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
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


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"},
)
2 changes: 1 addition & 1 deletion tests/app/domain/comments/test_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=[],
Expand Down

0 comments on commit 6b4a0b9

Please sign in to comment.