Initial commit
This commit is contained in:
25
backend/app/models/trend.py
Normal file
25
backend/app/models/trend.py
Normal file
@@ -0,0 +1,25 @@
|
||||
from sqlalchemy import Column, Integer, String, Date, Float, ForeignKey, Index, UniqueConstraint
|
||||
from sqlalchemy.orm import relationship
|
||||
|
||||
from app.database import Base
|
||||
|
||||
|
||||
class TrendScore(Base):
|
||||
__tablename__ = "trend_scores"
|
||||
|
||||
id = Column(Integer, primary_key=True, autoincrement=True)
|
||||
bill_id = Column(String, ForeignKey("bills.bill_id", ondelete="CASCADE"), nullable=False)
|
||||
score_date = Column(Date, nullable=False)
|
||||
newsapi_count = Column(Integer, default=0)
|
||||
gnews_count = Column(Integer, default=0)
|
||||
gtrends_score = Column(Float, default=0.0)
|
||||
composite_score = Column(Float, default=0.0)
|
||||
|
||||
bill = relationship("Bill", back_populates="trend_scores")
|
||||
|
||||
__table_args__ = (
|
||||
UniqueConstraint("bill_id", "score_date", name="uq_trend_scores_bill_date"),
|
||||
Index("ix_trend_scores_bill_id", "bill_id"),
|
||||
Index("ix_trend_scores_score_date", "score_date"),
|
||||
Index("ix_trend_scores_composite", "composite_score"),
|
||||
)
|
||||
Reference in New Issue
Block a user