From nobody Wed Apr 24 13:26:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=patchew-devel-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=patchew-devel-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1628269182; cv=none; d=zohomail.com; s=zohoarc; b=QTFnwEDeQZ4nZuLrHJQjgQc6itCBOIQeTLtaAG8ROlMvBPQb27ABIitO795K9P2RzKW4XzzI81tJzSl91Awpn8k7AT2tOb+v9KAud3LY535MPlPAw2qtP36rWqqS4Jo9vPLZsp7ZQvjt/U4+iGC3Ye7Xw8ddfWS/RtZhsRVx998= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628269182; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=U7/5YyyiKZ6qNpi7r+ODeQR2Tp/+mRdlCppodCa60Zg=; b=lXaSS1UjAZLDiPZ3b/8LmsfWXovTzr5VHqd+DNfsKkXzvG3f32F4IqqhGffx62vLIAXlFiLOQGsFm2jXHQa28SLw230xPXYXc7voaQvaxiECD9h333wQ+oxfM52H4ZAf0vYvQE6D2JBjAp6q93OKnrhXxCgaabTI3vqMARxNeWs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=patchew-devel-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 162826918247090.80813185632883; Fri, 6 Aug 2021 09:59:42 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-42-pSlByTTuNOC6xIpEkUISnA-1; Fri, 06 Aug 2021 12:59:40 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 21CAF1006C80; Fri, 6 Aug 2021 16:59:39 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 150512CB37; Fri, 6 Aug 2021 16:59:39 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 0AA7B181A2AA; Fri, 6 Aug 2021 16:59:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 176Gx00Y027381 for ; Fri, 6 Aug 2021 12:59:00 -0400 Received: by smtp.corp.redhat.com (Postfix) id DC7C2779D0; Fri, 6 Aug 2021 16:59:00 +0000 (UTC) Received: from avogadro.lan (unknown [10.39.193.251]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5549A6091B for ; Fri, 6 Aug 2021 16:59:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628269181; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=U7/5YyyiKZ6qNpi7r+ODeQR2Tp/+mRdlCppodCa60Zg=; b=aq+6bfBU1+nqiohp5vppvnYRs5hpqHaM/FoWxuPerDzraWiAJFvhtIOqOi+3reBxRzR58M ZpZ8N/W1fIhy2U680NeY+yypVwa+NgwN/JF/lkpVqH244CztPLLRUAxamFVLoXhGtz7HNs f8S1flZL61rCEosHwszM7BEoTp540ic= X-MC-Unique: pSlByTTuNOC6xIpEkUISnA-1 From: Paolo Bonzini To: patchew-devel@redhat.com Date: Fri, 6 Aug 2021 18:58:44 +0200 Message-Id: <20210806165844.140447-5-pbonzini@redhat.com> In-Reply-To: <20210806165844.140447-1-pbonzini@redhat.com> References: <20210806165844.140447-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: patchew-devel@redhat.com Subject: [Patchew-devel] [PATCH] tweak sorting to handle last_reply_date better X-BeenThere: patchew-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Patchew development and discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: patchew-devel-bounces@redhat.com Errors-To: patchew-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=patchew-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1628269183699100003 Content-Type: text/plain; charset="utf-8" Postgres treats NULL as larger than anything else, so the REST series view = starts with all messages that never had a reply. Sort by id instead for stability= and to get more obvious results. In the web view, place non-replied messages last and sort them by descendin= g date. Signed-off-by: Paolo Bonzini --- api/rest.py | 2 +- www/views.py | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/api/rest.py b/api/rest.py index de02857..b723997 100644 --- a/api/rest.py +++ b/api/rest.py @@ -540,7 +540,7 @@ class PatchewSearchFilter(filters.BaseFilterBackend): =20 class SeriesViewSet(BaseMessageViewSet): serializer_class =3D SeriesSerializer - queryset =3D Message.objects.filter(topic__isnull=3DFalse).order_by("-= last_reply_date") + queryset =3D Message.objects.filter(topic__isnull=3DFalse).order_by("-= id") filter_backends =3D (PatchewSearchFilter,) search_fields =3D (SEARCH_PARAM,) =20 diff --git a/www/views.py b/www/views.py index e20aa91..d8c40af 100644 --- a/www/views.py +++ b/www/views.py @@ -176,13 +176,11 @@ def prepare_navigate_list(cur, *path): def render_series_list_page(request, query, search=3DNone, project=3DNone,= keywords=3D[]): sort =3D request.GET.get("sort") if sort =3D=3D "replied": - sortfield =3D "-last_reply_date" + query =3D query.order_by(F('last_reply_date').desc(nulls_last=3DTr= ue), '-date') order_by_reply =3D True else: - sortfield =3D "-date" + query =3D query.order_by('-date') order_by_reply =3D False - if sortfield: - query =3D query.order_by(sortfield) query =3D query.prefetch_related("topic") cur_page =3D get_page_from_request(request) start =3D (cur_page - 1) * PAGE_SIZE --=20 2.31.1 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://listman.redhat.com/mailman/listinfo/patchew-devel