From 84924bc3f668fdcd5426ede043d5225af1e948b4 Mon Sep 17 00:00:00 2001 From: halo Date: Sat, 11 Dec 2021 22:23:29 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E4=BC=9A=E8=AF=9D?= =?UTF-8?q?=E8=AF=A6=E6=83=85=E9=A1=B5=E5=91=BD=E4=BB=A4=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E6=8E=92=E5=BA=8F=E5=A4=B1=E6=95=88bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/terminal/api/command.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/terminal/api/command.py b/apps/terminal/api/command.py index 9e3065e99..8b66652f1 100644 --- a/apps/terminal/api/command.py +++ b/apps/terminal/api/command.py @@ -121,8 +121,11 @@ class CommandViewSet(JMSBulkModelViewSet): qs = storage.get_command_queryset() commands = self.filter_queryset(qs) merged_commands.extend(commands[:]) # ES 默认只取 10 条数据 - - merged_commands.sort(key=lambda command: command.timestamp, reverse=True) + order = self.request.query_params.get('order', None) + if order == 'timestamp': + merged_commands.sort(key=lambda command: command.timestamp) + else: + merged_commands.sort(key=lambda command: command.timestamp, reverse=True) page = self.paginate_queryset(merged_commands) if page is not None: serializer = self.get_serializer(page, many=True)