all override add and remove now use new datastructures, close to be able to test / augment as per TODO

This commit is contained in:
2025-10-09 23:56:27 +11:00
parent 846bdc4e52
commit ee1c9b5494
6 changed files with 95 additions and 75 deletions

View File

@@ -180,74 +180,83 @@ class PathSchema(ma.SQLAlchemyAutoSchema):
class FileTypeSchema(ma.SQLAlchemyAutoSchema):
class Meta: model = FileType
load_instance = True
class Meta:
model = FileType
load_instance = True
class DirSchema(ma.SQLAlchemyAutoSchema):
class Meta: model = Dir
load_instance = True
class Meta:
model = Dir
load_instance = True
eid = ma.auto_field() # Explicitly include eid
in_path = ma.Nested(PathSchema)
class FaceFileLinkSchema(ma.SQLAlchemyAutoSchema):
class Meta: model = FaceFileLink
class Meta:
model = FaceFileLink
load_instance = True
model_used = ma.auto_field()
load_instance = True
class PersonSchema(ma.SQLAlchemyAutoSchema):
class Meta: model=Person
load_instance = True
class Meta:
model=Person
load_instance = True
class RefimgSchema(ma.SQLAlchemyAutoSchema):
class Meta:
model = Refimg
exclude = ('face',)
load_instance = True
load_instance = True
person = ma.Nested(PersonSchema)
class FaceRefimgLinkSchema(ma.SQLAlchemyAutoSchema):
class Meta: model = FaceRefimgLink
load_instance = True
class Meta:
model = FaceRefimgLink
load_instance = True
class FaceOverrideTypeSchema(ma.SQLAlchemyAutoSchema):
class Meta:
model = FaceOverrideType
load_instance = True
class FaceNoMatchOverrideSchema(ma.SQLAlchemyAutoSchema):
class Meta: model = FaceOverrideType
load_instance = True
type = ma.Nested(FaceOverrideType)
class Meta:
model = FaceNoMatchOverride
load_instance = True
type = ma.Nested(FaceOverrideTypeSchema)
class FaceForceMatchOverrideSchema(ma.SQLAlchemyAutoSchema):
class Meta: model = FaceOverrideType
load_instance = True
person = ma.Nested(Person)
class Meta:
model = FaceForceMatchOverride
load_instance = True
person = ma.Nested(PersonSchema)
class FaceSchema(ma.SQLAlchemyAutoSchema):
class Meta:
model=Face
exclude = ('face',)
load_instance = True
load_instance = True
refimg = ma.Nested(RefimgSchema,allow_none=True)
# faces have to come with a file connection
facefile_lnk = ma.Nested(FaceFileLinkSchema)
refimg_lnk = ma.Nested(FaceRefimgLinkSchema,allow_none=True)
fnmo = ma.Nested( FaceNoMatchOverride, allow_none=True )
ffmo = ma.Nested( FaceForceMatchOverride, allow_none=True )
fnmo = ma.Nested( FaceNoMatchOverrideSchema, allow_none=True, many=True )
ffmo = ma.Nested( FaceForceMatchOverrideSchema, allow_none=True, many=True )
class FileSchema(ma.SQLAlchemyAutoSchema):
class Meta: model = File
load_instance = True
class Meta:
model = File
load_instance = True
faces = ma.Nested(FaceSchema,many=True,allow_none=True)
# used just in NMO var
class FaceOverrideTypeSchema(ma.SQLAlchemyAutoSchema):
class Meta: model = FaceOverrideType
load_instance = True
################################################################################
# Schema for Entry so we can json for data to the client
################################################################################
class EntrySchema(ma.SQLAlchemyAutoSchema):
# gives id, name, type_id
class Meta: model = Entry
load_instance = True
class Meta:
model = Entry
load_instance = True
type = ma.Nested(FileTypeSchema)
file_details = ma.Nested(FileSchema,allow_none=True)
@@ -284,6 +293,8 @@ def process_ids():
joinedload(Entry.file_details).joinedload(File.faces).joinedload(Face.refimg).joinedload(Refimg.person),
joinedload(Entry.file_details).joinedload(File.faces).joinedload(Face.refimg_lnk),
joinedload(Entry.file_details).joinedload(File.faces).joinedload(Face.facefile_lnk),
joinedload(Entry.file_details).joinedload(File.faces).joinedload(Face.fnmo).joinedload(FaceNoMatchOverride.type),
joinedload(Entry.file_details).joinedload(File.faces).joinedload(Face.ffmo).joinedload(FaceForceMatchOverride.person),
)
.where(Entry.id.in_(ids))
)