Spaces:
Sleeping
Sleeping
Download backend/database/models.py from ashutoshneemval/CLAT_Guide: direct link, hf CLI and curl.
- Browser
- Download file 1.97 kB
-
https://huggingface.co/spaces/ashutoshneemval/CLAT_Guide/resolve/main/backend/database/models.py
- Command line
-
hf download hf://spaces/ashutoshneemval/CLAT_Guide/backend/database/models.py
-
curl -L -o models.py https://huggingface.co/spaces/ashutoshneemval/CLAT_Guide/resolve/main/backend/database/models.py
1.97 kB
| from sqlalchemy import Column, Integer, String, Boolean, DateTime, ForeignKey, Float, JSON | |
| from sqlalchemy.orm import relationship | |
| from sqlalchemy.sql import func | |
| from database.connection import Base | |
| class User(Base): | |
| __tablename__ = "users" | |
| id = Column(Integer, primary_key=True, index=True) | |
| email = Column(String, unique=True, index=True, nullable=False) | |
| hashed_password = Column(String, nullable=False) | |
| is_active = Column(Boolean, default=True) | |
| created_at = Column(DateTime(timezone=True), server_default=func.now()) | |
| documents = relationship("UploadedDocument", back_populates="owner", cascade="all, delete-orphan") | |
| analytics = relationship("UserAnalytics", back_populates="user", cascade="all, delete-orphan") | |
| class UploadedDocument(Base): | |
| __tablename__ = "uploaded_documents" | |
| id = Column(Integer, primary_key=True, index=True) | |
| filename = Column(String, nullable=False) | |
| file_path = Column(String, nullable=False) | |
| file_type = Column(String, nullable=False) | |
| chunk_count = Column(Integer, default=0) | |
| uploaded_at = Column(DateTime(timezone=True), server_default=func.now()) | |
| user_id = Column(Integer, ForeignKey("users.id"), nullable=False) | |
| owner = relationship("User", back_populates="documents") | |
| class UserAnalytics(Base): | |
| __tablename__ = "user_analytics" | |
| id = Column(Integer, primary_key=True, index=True) | |
| user_id = Column(Integer, ForeignKey("users.id"), nullable=False) | |
| subject = Column(String, nullable=False, index=True) # English, GK, Legal, Logical, Quant | |
| topic = Column(String, nullable=False) # e.g., Contract Law, Torts, RCs | |
| attempts = Column(Integer, default=0) | |
| correct_attempts = Column(Integer, default=0) | |
| total_time_spent = Column(Float, default=0.0) # in seconds | |
| last_updated = Column(DateTime(timezone=True), onupdate=func.now(), server_default=func.now()) | |
| user = relationship("User", back_populates="analytics") | |