Self-hosted US Congress monitoring platform with AI policy briefs, bill/member/topic follows, ntfy + RSS + email notifications, alignment scoring, collections, and draft-letter generator. Authored by: Jack Levy
54 lines
2.0 KiB
Python
54 lines
2.0 KiB
Python
from sqlalchemy import Column, Date, DateTime, ForeignKey, Index, Integer, String, Text, UniqueConstraint
|
|
from sqlalchemy.orm import relationship
|
|
from sqlalchemy.sql import func
|
|
|
|
from app.database import Base
|
|
|
|
|
|
class BillVote(Base):
|
|
__tablename__ = "bill_votes"
|
|
|
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
|
bill_id = Column(String, ForeignKey("bills.bill_id", ondelete="CASCADE"), nullable=False)
|
|
congress = Column(Integer, nullable=False)
|
|
chamber = Column(String(50), nullable=False)
|
|
session = Column(Integer, nullable=False)
|
|
roll_number = Column(Integer, nullable=False)
|
|
question = Column(Text)
|
|
description = Column(Text)
|
|
vote_date = Column(Date)
|
|
yeas = Column(Integer)
|
|
nays = Column(Integer)
|
|
not_voting = Column(Integer)
|
|
result = Column(String(200))
|
|
source_url = Column(String)
|
|
fetched_at = Column(DateTime(timezone=True))
|
|
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
|
|
|
positions = relationship("MemberVotePosition", back_populates="vote", cascade="all, delete-orphan")
|
|
|
|
__table_args__ = (
|
|
Index("ix_bill_votes_bill_id", "bill_id"),
|
|
UniqueConstraint("congress", "chamber", "session", "roll_number", name="uq_bill_votes_roll"),
|
|
)
|
|
|
|
|
|
class MemberVotePosition(Base):
|
|
__tablename__ = "member_vote_positions"
|
|
|
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
|
vote_id = Column(Integer, ForeignKey("bill_votes.id", ondelete="CASCADE"), nullable=False)
|
|
bioguide_id = Column(String, ForeignKey("members.bioguide_id", ondelete="SET NULL"), nullable=True)
|
|
member_name = Column(String(200))
|
|
party = Column(String(50))
|
|
state = Column(String(10))
|
|
position = Column(String(50), nullable=False)
|
|
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
|
|
|
vote = relationship("BillVote", back_populates="positions")
|
|
|
|
__table_args__ = (
|
|
Index("ix_member_vote_positions_vote_id", "vote_id"),
|
|
Index("ix_member_vote_positions_bioguide_id", "bioguide_id"),
|
|
)
|