Files
core/orm/author.py

48 lines
1.7 KiB
Python
Raw Normal View History

2023-11-03 13:10:22 +03:00
import time
2023-11-22 19:38:39 +03:00
2024-01-25 22:41:27 +03:00
from sqlalchemy import JSON, Boolean, Column, ForeignKey, Integer, String
2024-02-25 16:43:04 +03:00
2023-10-25 19:55:30 +03:00
from services.db import Base
2023-10-23 17:47:11 +03:00
2024-05-07 00:06:31 +03:00
# from sqlalchemy_utils import TSVectorType
2023-10-23 17:47:11 +03:00
class AuthorRating(Base):
2024-04-17 18:32:23 +03:00
__tablename__ = "author_rating"
2023-10-23 17:47:11 +03:00
id = None # type: ignore
2024-04-17 18:32:23 +03:00
rater = Column(ForeignKey("author.id"), primary_key=True)
author = Column(ForeignKey("author.id"), primary_key=True)
2023-11-29 23:22:39 +03:00
plus = Column(Boolean)
2023-10-23 17:47:11 +03:00
class AuthorFollower(Base):
2024-04-17 18:32:23 +03:00
__tablename__ = "author_follower"
2023-10-23 17:47:11 +03:00
id = None # type: ignore
2024-04-17 18:32:23 +03:00
follower = Column(ForeignKey("author.id"), primary_key=True)
author = Column(ForeignKey("author.id"), primary_key=True)
2023-11-03 13:10:22 +03:00
created_at = Column(Integer, nullable=False, default=lambda: int(time.time()))
2023-10-23 17:47:11 +03:00
auto = Column(Boolean, nullable=False, default=False)
class Author(Base):
2024-04-17 18:32:23 +03:00
__tablename__ = "author"
2023-10-23 17:47:11 +03:00
2024-02-21 10:27:16 +03:00
user = Column(String) # unbounded link with authorizer's User type
2023-11-03 13:10:22 +03:00
2024-04-17 18:32:23 +03:00
name = Column(String, nullable=True, comment="Display name")
2024-02-19 17:22:38 +03:00
slug = Column(String, unique=True, comment="Author's slug")
2024-04-17 18:32:23 +03:00
bio = Column(String, nullable=True, comment="Bio") # status description
about = Column(String, nullable=True, comment="About") # long and formatted
pic = Column(String, nullable=True, comment="Picture")
links = Column(JSON, nullable=True, comment="Links")
2023-11-03 13:10:22 +03:00
created_at = Column(Integer, nullable=False, default=lambda: int(time.time()))
last_seen = Column(Integer, nullable=False, default=lambda: int(time.time()))
updated_at = Column(Integer, nullable=False, default=lambda: int(time.time()))
2024-04-17 18:32:23 +03:00
deleted_at = Column(Integer, nullable=True, comment="Deleted at")
2024-02-25 16:43:04 +03:00
2024-04-27 01:43:42 +03:00
# search_vector = Column(
# TSVectorType("name", "slug", "bio", "about", regconfig="pg_catalog.russian")
# )