feat: Added hidden boolean column to Creator model, migration marking T…
- "backend/models.py" - "backend/routers/creators.py" - "alembic/versions/009_add_creator_hidden_flag.py" GSD-Task: S02/T01
This commit is contained in:
parent
d5144307b8
commit
831489cf4f
3 changed files with 31 additions and 2 deletions
28
alembic/versions/009_add_creator_hidden_flag.py
Normal file
28
alembic/versions/009_add_creator_hidden_flag.py
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
"""Add hidden boolean flag to creators table.
|
||||
|
||||
Marks test/internal creators as hidden so they are filtered from
|
||||
public API responses.
|
||||
|
||||
Revision ID: 009_add_creator_hidden_flag
|
||||
Revises: 008_rename_processing_status
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
revision = "009_add_creator_hidden_flag"
|
||||
down_revision = "008_rename_processing_status"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
op.add_column(
|
||||
"creators",
|
||||
sa.Column("hidden", sa.Boolean(), server_default="false", nullable=False),
|
||||
)
|
||||
# Mark known test creator as hidden
|
||||
op.execute("UPDATE creators SET hidden = true WHERE slug = 'testcreator'")
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
op.drop_column("creators", "hidden")
|
||||
|
|
@ -104,6 +104,7 @@ class Creator(Base):
|
|||
genres: Mapped[list[str] | None] = mapped_column(ARRAY(String), nullable=True)
|
||||
folder_name: Mapped[str] = mapped_column(String(255), nullable=False)
|
||||
view_count: Mapped[int] = mapped_column(Integer, default=0, server_default="0")
|
||||
hidden: Mapped[bool] = mapped_column(default=False, server_default="false")
|
||||
created_at: Mapped[datetime] = mapped_column(
|
||||
default=_now, server_default=func.now()
|
||||
)
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ async def list_creators(
|
|||
Creator,
|
||||
technique_count_sq.label("technique_count"),
|
||||
video_count_sq.label("video_count"),
|
||||
)
|
||||
).where(Creator.hidden != True) # noqa: E712
|
||||
|
||||
# Genre filter
|
||||
if genre:
|
||||
|
|
@ -81,7 +81,7 @@ async def list_creators(
|
|||
)
|
||||
|
||||
# Get total count (without offset/limit)
|
||||
count_stmt = select(func.count()).select_from(Creator)
|
||||
count_stmt = select(func.count()).select_from(Creator).where(Creator.hidden != True) # noqa: E712
|
||||
if genre:
|
||||
count_stmt = count_stmt.where(Creator.genres.any(genre))
|
||||
total = (await db.execute(count_stmt)).scalar() or 0
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue