feat(phash): import_settings.phash_threshold (migration 0006) exposed + validated in API

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-17 22:04:13 -04:00
parent d2e8dd3a3b
commit 9ef5e5047d
4 changed files with 67 additions and 0 deletions
+11
View File
@@ -17,6 +17,7 @@ _EDITABLE_FIELDS = (
"skip_single_color",
"single_color_threshold",
"single_color_tolerance",
"phash_threshold",
)
@@ -34,6 +35,7 @@ async def get_import_settings():
"skip_single_color": row.skip_single_color,
"single_color_threshold": row.single_color_threshold,
"single_color_tolerance": row.single_color_tolerance,
"phash_threshold": row.phash_threshold,
})
@@ -43,6 +45,15 @@ async def update_import_settings():
if not isinstance(body, dict):
return jsonify({"error": "body must be a JSON object"}), 400
if "phash_threshold" in body and (
not isinstance(body["phash_threshold"], int)
or isinstance(body["phash_threshold"], bool)
or body["phash_threshold"] < 0
):
return jsonify(
{"error": "phash_threshold must be a non-negative integer"}
), 400
async with get_session() as session:
row = (
await session.execute(select(ImportSettings).where(ImportSettings.id == 1))