Browse Source

Marking the last piece of data on each page is a duplicate issue, which can be solved by adding the id field to the order by rig and using a unique field (#9799)

Signed-off-by: root <root@localhost.localdomain>
Co-authored-by: root <root@localhost.localdomain>
yuanboao 6 months ago
parent
commit
4693080ce0
1 changed files with 2 additions and 2 deletions
  1. 2 2
      api/services/annotation_service.py

+ 2 - 2
api/services/annotation_service.py

@@ -132,14 +132,14 @@ class AppAnnotationService:
                         MessageAnnotation.content.ilike("%{}%".format(keyword)),
                     )
                 )
-                .order_by(MessageAnnotation.created_at.desc())
+                .order_by(MessageAnnotation.created_at.desc(), MessageAnnotation.id.desc())
                 .paginate(page=page, per_page=limit, max_per_page=100, error_out=False)
             )
         else:
             annotations = (
                 db.session.query(MessageAnnotation)
                 .filter(MessageAnnotation.app_id == app_id)
-                .order_by(MessageAnnotation.created_at.desc())
+                .order_by(MessageAnnotation.created_at.desc(), MessageAnnotation.id.desc())
                 .paginate(page=page, per_page=limit, max_per_page=100, error_out=False)
             )
         return annotations.items, annotations.total