feat: projekte und suche im backend

Projekte pro Benutzer mit Name und Farbe, Clips optional einem Projekt
zugeordnet. Löschen eines Projekts verschiebt seine Clips nach "ohne
Projekt". Clip-Liste filtert nach Projekt und sucht Teiltexte in Titel
und Inhalt, unabhängig von Groß-/Kleinschreibung (auch Umlaute).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
dbildhauerandClaude Opus 5.5 committed 2026-10-25 13:15:05 +01:00
1 parent 848cff35b3
commit ff2860f7be
13 files changed
+711 -9

No files matched your search

+10 -2
View File
@@ -12,7 +12,10 @@ from app.ws.hub import hub
router = APIRouter(prefix="/clips", tags=["clips"])
# Fields that may be null on purpose (clearing them); all others are ignored when null
_NULLABLE_FIELDS = {"title", "language"}
_NULLABLE_FIELDS = {"title", "language", "project_id"}
# "none" or a project id
_PROJECT_FILTER = r"^(none|[1-9][0-9]{0,17})$"
def _notify(background: BackgroundTasks, user_id: int, event: str, data: dict) -> None:
@@ -38,8 +41,13 @@ def list_clips(
db: DbSession,
limit: Annotated[int, Query(ge=1, le=100)] = 50,
offset: Annotated[int, Query(ge=0)] = 0,
project: Annotated[str | None, Query(pattern=_PROJECT_FILTER)] = None,
q: Annotated[str | None, Query(max_length=clip_service.SEARCH_MAX_LENGTH)] = None,
) -> ClipList:
items, total = clip_service.list_clips(db, user.id, limit, offset)
project_filter = project if project in (None, clip_service.NO_PROJECT) else int(project)
items, total = clip_service.list_clips(
db, user.id, limit, offset, project=project_filter, query=q
)
return ClipList(items=[ClipOut.model_validate(c) for c in items], total=total)