From 846bdc4e52ecd08fcfdd33fb77687f505c9d0476 Mon Sep 17 00:00:00 2001 From: Damien De Paoli Date: Tue, 7 Oct 2025 23:52:06 +1100 Subject: [PATCH] fix up linking between face to refimg when we add that face to a person from right-click --- TODO | 4 ++-- person.py | 10 +++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/TODO b/TODO index 1582dda..9cb8e1b 100644 --- a/TODO +++ b/TODO @@ -1,8 +1,8 @@ ### # # fix all face, right-click options: -# partial fix for face to new and existing person - the person and refimg -# data are correct, but the face_file_link is not connected (do this in person) - and if we do run AI jobs, they will overwrite it anyway (watch out for race condition) +# [DONE] add to new, add to existing +# [TODO] 4 x override* # #1 get override data into view # also all the add ref img/add override, etc are non-functional - FIX the override* stuff first to get table/naming consistency as that is half the problem diff --git a/person.py b/person.py index 556caa4..2b6c664 100644 --- a/person.py +++ b/person.py @@ -295,6 +295,7 @@ def find_persons(who): class FaceRefimgLinkSchema(ma.SQLAlchemyAutoSchema): class Meta: model = FaceRefimgLink + face_distance = ma.auto_field() # Explicitly include face_distance load_instance = True class PersonSchema(ma.SQLAlchemyAutoSchema): @@ -331,6 +332,11 @@ def add_refimg_to_person(): fname=TempRefimgFile( request.form['refimg_data'], p.tag ) r=AddRefimgToPerson( fname, p ) + # connect the refimg to the face in the db, now we have added this refimg to the person + frl=FaceRefimgLink( face_id=f.id, refimg_id=r.id, face_distance=0 ) + db.session.add(frl) + db.session.commit() + if request.form['search'] == "true": jex=[] ptype=PathType.query.filter(PathType.name=='Import').first() @@ -346,8 +352,10 @@ def add_refimg_to_person(): refimg_schema=RefimgSchema(many=False) r_data=refimg_schema.dump(r) + frl_schema=FaceRefimgLinkSchema(many=False) + frl_data=refimg_schema.dump(r) - return make_response( jsonify( refimg=r_data, who=p.tag, distance='0.0' ) ) + return make_response( jsonify( refimg=r_data, frl=frl_data ) ) ################################################################################ # /add_force_match_override -> POST