Browse Source

Orders content revisions by updated date

Adrien Panay 7 years ago
parent
commit
2abddec179
1 changed files with 9 additions and 1 deletions
  1. 9 1
      tracim/tracim/model/data.py

+ 9 - 1
tracim/tracim/model/data.py View File

735
     revision_to_serialize = -0  # This flag allow to serialize a given revision if required by the user
735
     revision_to_serialize = -0  # This flag allow to serialize a given revision if required by the user
736
 
736
 
737
     id = Column(Integer, primary_key=True)
737
     id = Column(Integer, primary_key=True)
738
+    # TODO - A.P - 2017-09-05 - revisions default sorting
739
+    # The only sorting that makes sens is ordering by "updated" field. But:
740
+    # - its content will soon replace the one of "created",
741
+    # - this "updated" field will then be dropped.
742
+    # So for now, we order by "updated" explicitly, but remember to switch to
743
+    # "created" once "updated" removed.
744
+    # https://github.com/tracim/tracim/issues/336
738
     revisions = relationship("ContentRevisionRO",
745
     revisions = relationship("ContentRevisionRO",
739
                              foreign_keys=[ContentRevisionRO.content_id],
746
                              foreign_keys=[ContentRevisionRO.content_id],
740
-                             back_populates="node")
747
+                             back_populates="node",
748
+                             order_by="ContentRevisionRO.updated")
741
     children_revisions = relationship("ContentRevisionRO",
749
     children_revisions = relationship("ContentRevisionRO",
742
                                       foreign_keys=[ContentRevisionRO.parent_id],
750
                                       foreign_keys=[ContentRevisionRO.parent_id],
743
                                       back_populates="parent")
751
                                       back_populates="parent")