Some checks failed
build-images / web (push) Has been cancelled
vision2026-ci / Python SDK resource tests (push) Has been cancelled
build-images / api (push) Has been cancelled
build-images / worker-gpu (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (comfy-workflow-schema) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (effects-core) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (eventbus-types) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (growth-analytics) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (provider-adapter-kit) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (publishing-connectors) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (render-core) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (shot-template-schema) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (trends-schema) (push) Has been cancelled
vision2026-ci / Desktop engine crates (test + clippy + fmt) (push) Has been cancelled
codeql / Analyze (javascript-typescript) (push) Has been cancelled
codeql / Analyze (python) (push) Has been cancelled
perf / API hot-path micro-smoke (budgeted) (push) Has been cancelled
perf / Desktop engine crates (release build check) (push) Has been cancelled
vision2026-ci / API phase modules (ruff + pytest) (push) Has been cancelled
vision2026-ci / Alembic upgrade + drift check (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (caption-engine) (push) Has been cancelled
Paid, hosted product at menivor.com, now retired as a company project. Fresh squashed history of the cleaned working tree (secret-scanned, no .env, no customer data, no outreach logs). Built on MoneyPrinterTurbo (MIT, harry0703) — see NOTICE.
72 lines
2.0 KiB
Python
72 lines
2.0 KiB
Python
"""Session-injected MotionRender repository.
|
|
|
|
CRUD + owner-scoped reads for ``motion_renders``. Never opens its own session
|
|
(``add`` + ``flush`` only) — the router owns the ``get_session`` lifecycle so the
|
|
pure motion service stays pure.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Any
|
|
|
|
from app.models.db.motion import MotionRender
|
|
|
|
|
|
class MotionRenderRepository:
|
|
"""CRUD for the motion-render audit rows."""
|
|
|
|
def __init__(self, session: Any) -> None:
|
|
self._s = session
|
|
|
|
def create(
|
|
self,
|
|
*,
|
|
user_id: str,
|
|
preset_id: str,
|
|
motion_class: str,
|
|
intensity: int,
|
|
plan: dict,
|
|
provider_key: str = "",
|
|
provider_run_id: str = "",
|
|
output_ref: str = "",
|
|
) -> MotionRender:
|
|
row = MotionRender(
|
|
user_id=user_id,
|
|
preset_id=preset_id,
|
|
motion_class=motion_class,
|
|
intensity=int(intensity),
|
|
provider_key=provider_key,
|
|
provider_run_id=provider_run_id,
|
|
output_ref=output_ref,
|
|
plan=dict(plan or {}),
|
|
)
|
|
self._s.add(row)
|
|
self._s.flush()
|
|
return row
|
|
|
|
def get(self, render_id: str) -> MotionRender | None:
|
|
return self._s.get(MotionRender, render_id)
|
|
|
|
def get_owned(self, render_id: str, user_id: str) -> MotionRender | None:
|
|
row = self._s.get(MotionRender, render_id)
|
|
if row is None or row.user_id != user_id:
|
|
return None
|
|
return row
|
|
|
|
def list_for_user(self, user_id: str, *, limit: int = 50) -> list[MotionRender]:
|
|
return (
|
|
self._s.query(MotionRender)
|
|
.filter(MotionRender.user_id == user_id)
|
|
.order_by(MotionRender.created_at.desc())
|
|
.limit(limit)
|
|
.all()
|
|
)
|
|
|
|
def delete_owned(self, render_id: str, user_id: str) -> bool:
|
|
row = self.get_owned(render_id, user_id)
|
|
if row is None:
|
|
return False
|
|
self._s.delete(row)
|
|
self._s.flush()
|
|
return True
|