From 4693080ce01d63513b6dae15fa01a6d694d57815 Mon Sep 17 00:00:00 2001 From: yuanboao <79826960+yuanboao@users.noreply.github.com> Date: Fri, 25 Oct 2024 15:34:58 +0800 Subject: [PATCH] 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 Co-authored-by: root --- api/services/annotation_service.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/services/annotation_service.py b/api/services/annotation_service.py index 3cc6c51c2d..915d37ec03 100644 --- a/api/services/annotation_service.py +++ b/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