Skip to content

Commit

Permalink
Fix sorting report atrributes to respect user order (#343)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
Progress1 and Jan Polonsky authored Aug 13, 2024
1 parent 3675033 commit d12a944
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/core/model/report_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit d12a944

Please sign in to comment.