fix: 修复会话详情页命令列表排序失效bug

pull/7367/head
halo 3 years ago committed by 老广
parent 2de769ecad
commit 84924bc3f6

@ -121,8 +121,11 @@ class CommandViewSet(JMSBulkModelViewSet):
qs = storage.get_command_queryset() qs = storage.get_command_queryset()
commands = self.filter_queryset(qs) commands = self.filter_queryset(qs)
merged_commands.extend(commands[:]) # ES 默认只取 10 条数据 merged_commands.extend(commands[:]) # ES 默认只取 10 条数据
order = self.request.query_params.get('order', None)
merged_commands.sort(key=lambda command: command.timestamp, reverse=True) 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) page = self.paginate_queryset(merged_commands)
if page is not None: if page is not None:
serializer = self.get_serializer(page, many=True) serializer = self.get_serializer(page, many=True)

Loading…
Cancel
Save