Spaces:
Configuration error
Configuration error
| from sqlalchemy import ( | |
| Column, | |
| Integer, | |
| String, | |
| Float, | |
| Date, | |
| Time, | |
| DateTime, | |
| ForeignKey, | |
| UniqueConstraint, | |
| func, | |
| ) | |
| from sqlalchemy.dialects.postgresql import ARRAY | |
| from sqlalchemy.orm import relationship | |
| from app.database.database import Base | |
| class Person(Base): | |
| __tablename__ = "person" | |
| id = Column(Integer, primary_key=True, index=True) | |
| name = Column(String, nullable=False, index=True) | |
| embedding = Column(ARRAY(Float), nullable=False) # 512-d embedding | |
| created_at = Column(DateTime(timezone=True), server_default=func.now()) | |
| attendances = relationship("Attendance", back_populates="person") | |
| class Attendance(Base): | |
| __tablename__ = "attendance" | |
| # شخص واحد يتسجل مرة واحدة بس فى اليوم | |
| __table_args__ = (UniqueConstraint("person_id", "date", name="uq_person_date"),) | |
| id = Column(Integer, primary_key=True, index=True) | |
| person_id = Column(Integer, ForeignKey("person.id"), nullable=False) | |
| date = Column(Date, nullable=False) | |
| time = Column(Time, nullable=False) | |
| status = Column(String, default="Present") | |
| person = relationship("Person", back_populates="attendances") | |