include refimg_lnk and facefile_lnk into Face to be used in viewer
This commit is contained in:
10
files.py
10
files.py
@@ -183,6 +183,7 @@ class DirSchema(ma.SQLAlchemyAutoSchema):
|
|||||||
|
|
||||||
class FaceFileLinkSchema(ma.SQLAlchemyAutoSchema):
|
class FaceFileLinkSchema(ma.SQLAlchemyAutoSchema):
|
||||||
class Meta: model = FaceFileLink
|
class Meta: model = FaceFileLink
|
||||||
|
model_used = ma.auto_field()
|
||||||
load_instance = True
|
load_instance = True
|
||||||
|
|
||||||
class PersonSchema(ma.SQLAlchemyAutoSchema):
|
class PersonSchema(ma.SQLAlchemyAutoSchema):
|
||||||
@@ -206,6 +207,9 @@ class FaceSchema(ma.SQLAlchemyAutoSchema):
|
|||||||
exclude = ('face',)
|
exclude = ('face',)
|
||||||
load_instance = True
|
load_instance = True
|
||||||
refimg = ma.Nested(RefimgSchema,allow_none=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)
|
||||||
|
|
||||||
class FileSchema(ma.SQLAlchemyAutoSchema):
|
class FileSchema(ma.SQLAlchemyAutoSchema):
|
||||||
class Meta: model = File
|
class Meta: model = File
|
||||||
@@ -268,12 +272,14 @@ def process_ids():
|
|||||||
stmt = (
|
stmt = (
|
||||||
select(Entry)
|
select(Entry)
|
||||||
.options(
|
.options(
|
||||||
joinedload(Entry.file_details).joinedload(File.faces),
|
joinedload(Entry.file_details).joinedload(File.faces).joinedload(Face.refimg).joinedload(Refimg.person),
|
||||||
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),
|
||||||
)
|
)
|
||||||
.where(Entry.id.in_(ids))
|
.where(Entry.id.in_(ids))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# unique as the ORM query returns a Cartesian product for the joins. E.g if file has 3 faces, the result has 3 rows of the same entry and file data, but different face data
|
# unique as the ORM query returns a Cartesian product for the joins. E.g if file has 3 faces, the result has 3 rows of the same entry and file data, but different face data
|
||||||
data=db.session.execute(stmt).unique().scalars().all()
|
data=db.session.execute(stmt).unique().scalars().all()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user