channel_content_data.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334
  1. from __future__ import annotations
  2. from sqlalchemy import BigInteger, Double, Index, String, UniqueConstraint, text
  3. from sqlalchemy.orm import Mapped, mapped_column
  4. from supply_infra.db.base import Base
  5. class ChannelContentData(Base):
  6. """Daily WeChat article read-rate snapshot imported from ODPS."""
  7. __tablename__ = "channel_content_data"
  8. __table_args__ = (
  9. UniqueConstraint(
  10. "channel_content_id",
  11. "dt",
  12. name="uk_channel_content_data_content_dt",
  13. ),
  14. Index("idx_channel_content_data_dt", "dt"),
  15. )
  16. id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True)
  17. account_uid: Mapped[str | None] = mapped_column(
  18. String(128), nullable=True, comment="公众号账号UID"
  19. )
  20. channel_content_id: Mapped[str] = mapped_column(String(128), nullable=False)
  21. read_cnt: Mapped[float | None] = mapped_column(Double, nullable=True)
  22. like_cnt: Mapped[float | None] = mapped_column(Double, nullable=True)
  23. avg_read_cnt_30d: Mapped[float | None] = mapped_column(Double, nullable=True)
  24. cal_fans_num: Mapped[float | None] = mapped_column(Double, nullable=True)
  25. avg_read_rate: Mapped[float] = mapped_column(Double, nullable=False, server_default=text("0"))
  26. like_rate: Mapped[float] = mapped_column(Double, nullable=False, server_default=text("0"))
  27. read_rate: Mapped[float] = mapped_column(Double, nullable=False, server_default=text("0"))
  28. dt: Mapped[str] = mapped_column(String(8), nullable=False)