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.
57 lines
2.2 KiB
Python
57 lines
2.2 KiB
Python
"""One-click publish (MV1): a creator's finished reels become a live channel in one press.
|
|
|
|
Picks the creator's newest finished, kept, unblocked renders (up to ``limit``),
|
|
creates the channel if needed, adds each as a title, runs the compliance gate
|
|
and publishes every title that passes. The elapsed time is measured and
|
|
returned, so the "5 reels to a channel in under 60 s" target is shown per run.
|
|
Titles that fail the gate stay drafts and are listed with the reason.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import time
|
|
from typing import Any
|
|
|
|
from sqlalchemy import select
|
|
from sqlalchemy.orm import Session
|
|
|
|
from . import service
|
|
from .models import STATUS_PUBLISHED
|
|
|
|
TARGET_SECONDS = 60.0
|
|
|
|
|
|
def finished_reels(session: Session, user_id: str, limit: int) -> list[Any]:
|
|
from app.domains.reels import keep
|
|
from app.models.db.models import Job
|
|
|
|
rows = session.execute(
|
|
select(Job).where(Job.user_id == user_id, Job.state == service.TASK_STATE_COMPLETE, Job.result_key != "",
|
|
Job.deleted_at.is_(None)).order_by(Job.created_at.desc()).limit(limit * 3)
|
|
).scalars().all()
|
|
return [job for job in rows if not keep.is_pending(dict(job.params or {}))][:limit]
|
|
|
|
|
|
def publish_all(session: Session, user_id: str, *, limit: int = 12, clock=time.monotonic) -> dict[str, Any]:
|
|
started = clock()
|
|
channel = service.ensure_channel(session, user_id)
|
|
published, held = [], []
|
|
for job in finished_reels(session, user_id, limit):
|
|
title = service.add_title(session, user_id, job.id)
|
|
if title.status == STATUS_PUBLISHED:
|
|
published.append(title.id)
|
|
continue
|
|
reason = service.gate(session, title)
|
|
if reason:
|
|
held.append({"title_id": title.id, "reason": reason})
|
|
continue
|
|
service.publish_title(session, user_id, title.id)
|
|
published.append(title.id)
|
|
session.flush()
|
|
seconds = round(clock() - started, 3)
|
|
return {"channel": service.channel_view(session, channel), "published": published, "held": held,
|
|
"seconds": seconds, "target_seconds": TARGET_SECONDS, "within_target": seconds <= TARGET_SECONDS}
|
|
|
|
|
|
__all__ = ["TARGET_SECONDS", "finished_reels", "publish_all"]
|