From d12a944c212923df84ef2fdd6175246d6ed29304 Mon Sep 17 00:00:00 2001 From: Progress Date: Tue, 13 Aug 2024 10:40:45 +0200 Subject: [PATCH] Fix sorting report atrributes to respect user order (#343) * Fix sorting report atrributes to respect user order. This is caused by change: Opitimalization: tables relationship (join) #334 * remove unnecessary import --------- Co-authored-by: Jan Polonsky --- src/core/model/report_item.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/model/report_item.py b/src/core/model/report_item.py index 073df5bd..74dce4b4 100644 --- a/src/core/model/report_item.py +++ b/src/core/model/report_item.py @@ -115,7 +115,8 @@ class ReportItemAttribute(db.Model): current = db.Column(db.Boolean, default=True) attribute_group_item_id = db.Column(db.Integer, db.ForeignKey("attribute_group_item.id")) - attribute_group_item = db.relationship("AttributeGroupItem", viewonly=True, lazy="joined", order_by=AttributeGroupItem.index) + # for nice output there should be order_by also for AttributeGroup.index but there is problem reference sub table: AttributeGroupItem.attribute_group.index + attribute_group_item = db.relationship("AttributeGroupItem", viewonly=True, lazy="joined", order_by=[AttributeGroupItem.index, id]) attribute_group_item_title = db.Column(db.String) report_item_id = db.Column(db.Integer, db.ForeignKey("report_item.id"), nullable=True) @@ -312,7 +313,6 @@ def reconstruct(self): """ self.subtitle = "" self.tag = "mdi-file-table-outline" - self.attributes.sort(key=lambda obj: (obj.attribute_group_item.attribute_group.index, obj.attribute_group_item.index, obj.id)) @classmethod def count_all(cls, is_completed):