Spaces:
Running on Zero
Running on Zero
Download app/db/models/material.py from cipher-attacks/Dbu-central-bot: direct link, hf CLI and curl.
- Browser
- Download file 2.3 kB
-
https://huggingface.co/spaces/cipher-attacks/Dbu-central-bot/resolve/main/app/db/models/material.py
- Command line
-
hf download hf://spaces/cipher-attacks/Dbu-central-bot/app/db/models/material.py
-
curl -L -o material.py https://huggingface.co/spaces/cipher-attacks/Dbu-central-bot/resolve/main/app/db/models/material.py
2.3 kB
| from datetime import datetime | |
| from typing import Optional | |
| from sqlalchemy import BigInteger, Boolean, DateTime, ForeignKey, Integer, String, func | |
| from sqlalchemy.orm import Mapped, mapped_column | |
| from app.db.base import Base | |
| class Material(Base): | |
| """A file served to students by Telegram file_id. | |
| library_chat_id/library_message_id point to a backup copy in the private | |
| library channel (so files can be re-indexed if the bot token ever changes). | |
| """ | |
| __tablename__ = "materials" | |
| id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True) | |
| course_id: Mapped[Optional[int]] = mapped_column(ForeignKey("courses.id"), index=True) | |
| kind: Mapped[str] = mapped_column(String(16), default="slide") # slide|exam|note|book | |
| title: Mapped[str] = mapped_column(String(256)) | |
| file_id: Mapped[Optional[str]] = mapped_column(String(512)) | |
| orig_file_id: Mapped[Optional[str]] = mapped_column(String(512)) # the file as uploaded (before the stamp) | |
| watermarked: Mapped[bool] = mapped_column(Boolean, default=False, server_default="false") | |
| file_type: Mapped[str] = mapped_column(String(16), default="document", server_default="document") | |
| file_unique_id: Mapped[Optional[str]] = mapped_column(String(128), unique=True) | |
| content_hash: Mapped[Optional[str]] = mapped_column(String(64), index=True) # sha256 of the bytes | |
| text_sig: Mapped[Optional[int]] = mapped_column(BigInteger) # SimHash of the text (near-duplicates) | |
| pages: Mapped[Optional[int]] = mapped_column(Integer) | |
| size: Mapped[Optional[int]] = mapped_column(Integer) | |
| source_name: Mapped[Optional[str]] = mapped_column(String(256)) # original file name | |
| status: Mapped[str] = mapped_column(String(8), default="ok", server_default="ok") # ok | review | |
| credit: Mapped[Optional[str]] = mapped_column(String(40)) # contributor name, if they chose to be credited | |
| downloads: Mapped[int] = mapped_column(Integer, default=0, server_default="0") | |
| uploader_id: Mapped[Optional[int]] = mapped_column(BigInteger) | |
| library_chat_id: Mapped[Optional[int]] = mapped_column(BigInteger) | |
| library_message_id: Mapped[Optional[int]] = mapped_column(BigInteger) | |
| created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), server_default=func.now()) | |