feat: exclude source photos from automatic selection
Community checks / verify (push) Skipped
Verify Frame Flow / verify (push) Successful in 5m53s

This commit is contained in:
渡口浪人
2026-10-20 18:50:43 +08:00
parent e6a3974d08
commit 383ed45185
17 changed files with 735 additions and 23 deletions
+7 -2
View File
@@ -5,6 +5,7 @@ from io import BytesIO
from PIL import Image, ImageOps
from pigway_frame_flow.core.photo_preferences import eligible
from pigway_frame_flow.errors import ErrorCode as E
from pigway_frame_flow.errors import FlowError
from pigway_frame_flow.extensions.layout import LayoutInput, LayoutStudio
@@ -19,7 +20,11 @@ def prepare(service, content, device_id=None):
from pigway_frame_flow.extensions.quality import passes, photo_quality
source = service.photo_sources.get(content.source_id)
items = service.photo_sources.catalog(content.source_id)
items = eligible(
service.db,
content.source_id,
service.photo_sources.catalog(content.source_id),
)
candidates = rng.sample(items, min(len(items), content.count * 5))
for item in candidates:
try:
@@ -46,7 +51,7 @@ def prepare(service, content, device_id=None):
break
else:
rows = service.db.all(
"SELECT id AS asset_id FROM assets WHERE kind='images' ORDER BY created_at DESC LIMIT 10000"
"SELECT id AS asset_id FROM assets WHERE kind='images' AND NOT EXISTS (SELECT 1 FROM photo_preferences p WHERE p.source_id='@assets' AND p.item_id=assets.id AND p.excluded=1) ORDER BY created_at DESC LIMIT 10000"
)
ids = rng.sample(
[row["asset_id"] for row in rows], min(content.count, len(rows))