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:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user